镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Free the app path C string in the macOS app_icons table - #56148

Merged
lucasmrod merged 2 commits into
fleetdm:mainfrom
OvOhao:52655-app-icons-cstring-leak
Oct 26, 2026
Merged

lucasmrod merged 2 commits into
fleetdm:mainfrom
OvOhao:52655-app-icons-cstring-leak

Conversation

@OvOhao

@OvOhao OvOhao commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Related issue: Resolves #52655

getAppIcon passed C.CString(appPath) inline to the Objective-C Icon helper and never freed it, so each app_icons query leaked one C copy of the path. Icon only reads path (stringWithUTF8String: copies the bytes into a new NSString) and does not keep it, so the string is now bound and freed with defer C.free after the call. #include <stdlib.h> is added to the cgo preamble for C.free.

Checklist for submitter

  • Changes file added for user-visible changes in changes/, orbit/changes/ or ee/fleetd-chrome/changes.
    See Changes files for more information.

Testing

  • QA'd all new/changed functionality manually

On macOS (arm64), Go 1.27.3:

  • go build ./orbit/pkg/table/app-icons/ and go vet ./orbit/pkg/table/app-icons/ pass (the package has no tests).
  • A throwaway test (not included) called getAppIcon 20 times on /System/Applications/Calculator.app and ran under MallocStackLogging=1 leaks --atExit:
    • before: 21 leaks for 1008 total leaked bytes, 20 of them ROOT LEAK: <malloc in _cgo_..._Cfunc__Cmalloc> (48 bytes each, the path string)
    • after: 1 leak for 48 total leaked bytes, an xpc_date_t that is also present before the change; no _Cfunc__Cmalloc leaks

AI

AI: Claude Code (claude-opus-5-5)

fleetd/orbit/Fleet Desktop

  • If the change applies to only one platform, confirmed that runtime.GOOS is used as needed to isolate changes (the file is //go:build darwin)

Summary by CodeRabbit

  • Bug Fixes
    • Fixed a macOS memory leak that could occur when retrieving application icons repeatedly.
    • Prevented crashes when an application’s icon image cannot be loaded; the app now reports an error instead.

getAppIcon passed C.CString(appPath) inline to the Objective-C Icon
helper and never freed it. Icon only reads the bytes (stringWithUTF8String:
copies them), so free the string after the call.

Fixes fleetdm#52655
@OvOhao
OvOhao requested a review from a team as a code owner October 21, 2026 04:42
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: fleetdm/fleet
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: f647232
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7536ab43-1d35-4155-b162-61420890a7bc
Commits

Reviewing files that changed from the base of the PR and between 70e48c8 and 17c7939.

Files selected for processing: 2
  • orbit/changes/52655-app-icons-cstring-leak
  • orbit/pkg/table/app-icons/app_icons_darwin.go
Files skipped from review as they are similar to previous changes: 1
  • orbit/changes/52655-app-icons-cstring-leak

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

The Darwin Icon function now uses an autorelease pool, handles unavailable image data, and retains TIFF data. getAppIcon frees the C string created for the application path and returns an error when icon data is null. The changelog records these fixes.

Priority: Normal

Merge Risk: Minimal · up to 17c79

No concrete unresolved merge-blocking risk is established for the macOS app icon resource changes.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Out of Scope Changes check Warning The PR adds functional changes beyond the stated C-string fix. Icon now creates an autorelease pool, handles a null cgref, retains TIFF data, and releases brep. getAppIcon adds a new error pat… Remove the unrelated Icon ownership, autorelease-pool, and null-image changes from this PR, or move them to a separately scoped issue and pull request. Keep the C-string allocation, deferred C.free, required <stdlib.h> include, and re…
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly identifies the primary change: freeing the C string used for the macOS app icon path.
Description check Passed The description includes the related issue, explains the implementation, documents build, vet, and leak testing, identifies the macOS scope, and includes the required AI section. It is sufficiently co…
Linked Issues check Passed Issue #52655 requires freeing the C string passed to the macOS Icon helper. getAppIcon stores C.CString(appPath) in cPath, defers C.free(unsafe.Pointer(cPath)), and passes cPath to `C.Icon…
Full details: Description check

Explanation

The description includes the related issue, explains the implementation, documents build, vet, and leak testing, identifies the macOS scope, and includes the required AI section. It is sufficiently complete for this bug fix.

Full details: Linked Issues check

Explanation

Issue #52655 requires freeing the C string passed to the macOS Icon helper. getAppIcon stores C.CString(appPath) in cPath, defers C.free(unsafe.Pointer(cPath)), and passes cPath to C.Icon. The diff also adds &lt;stdlib.h&gt;. The related brep and imageData ownership notes are separate from this C-string requirement, so they are not required for compliance.

Full details: Out of Scope Changes check

Explanation

The PR adds functional changes beyond the stated C-string fix. Icon now creates an autorelease pool, handles a null cgref, retains TIFF data, and releases brep. getAppIcon adds a new error path for null data. These changes address separate ownership and crash concerns, not the linked issue's requested C-string fix.

Resolution

Remove the unrelated Icon ownership, autorelease-pool, and null-image changes from this PR, or move them to a separately scoped issue and pull request. Keep the C-string allocation, deferred C.free, required &lt;stdlib.h&gt; include, and related change-log entry.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.53%. Comparing base (8f9ac52) to head (17c7939).
⚠️ Report is 223 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #56148      +/-   ##
==========================================
+ Coverage   77.40%   77.53%   +0.13%     
==========================================
  Files        4335     4355      +20     
  Lines      270485   272644    +2159     
  Branches    15948    15948              
==========================================
+ Hits       209365   211398    +2033     
- Misses      60933    61059     +126     
  Partials      187      187              
Flag Coverage Δ
backend 78.81% <ø> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lucasmrod lucasmrod self-assigned this Oct 26, 2026

@lucasmrod lucasmrod left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I pushed some additional fixes.

@OvOhao Thanks for the contribution!

@lucasmrod
lucasmrod merged commit 77fa0d0 into fleetdm:main Oct 26, 2026
48 of 52 checks passed
allenhouchins added a commit that referenced this pull request Nov 6, 2026
**Related issue:** NA

Adds Fleet's November 2026 newsletter
(`articles/newsletter-2026-11.md`), which covers October 2026. It
publishes at `fleetdm.com/newsletters/newsletter-2026-11`.

- **Email subject line:** `Fleet news: November 2026`
- **Category:** `newsletter`, singular, which the website build accepts
(#52120). No website changes are needed.
- **Author:** Aube Paul (`robinedev`), matching the September and
October issues.

## Open questions for reviewers

- **New "📺 Fleet Virtual Summit" section** for the November 10 LinkedIn
Live event, placed before workshops. Keep it or fold it into the
workshops section. If it stays, it's a new entry in the newsletter's
section emoji table.
- **The roadmap preview is linked even though November isn't a quarter's
first month.** The October preview published October 13, after the
October issue went out, so readers haven't seen it in the newsletter
yet.
- **Article and guide picks are editorial**, not based on traffic
numbers. Reorder them if you have analytics. There were no case studies
in October.
- **The community section has one post, and it's personal.** Henry
Stamerjohann's MacSysAdmin talk. Fleet's company-page post about the
"Apple in the enterprise" research is another option, but it repeats the
research article in "Worth reading." No engagement numbers were
available.
- **Community contributors with five or more merged PRs in October:**
Prajwal Janbandhu (8, in the thank-you line), Michael Alt (6,
highlighted), Dhvanit (6, returning, not named), and Shreyash Agare (5,
returning, not named). Confirm none of them is a contractor whose
account isn't in the org.
- **Several first-time contributors only edited the handbook.** None
appear in Fleet's Slack, so they stay in the thank-you line.

## How each section was sourced

- **Shipped:** the Fleet 4.93.0 and 4.94.0 release articles,
cross-checked against tagged releases. The three highlights are macOS
patch notifications (Premium), Android zero-touch enrollment (Premium),
and self-service configuration profiles (not Premium), so the section
isn't all Premium. Patch releases 4.93.1 and 4.93.2 are covered by the
"See every release" link.
- **Planned:** the release planning board (view 10, filtered to
milestone 4.95.0), not the milestone fallback. There are 22 stories, all
assigned. 5.0.0 is due December 4, so November holds one release.
- **Workshops:** fleetdm.com/workshops, with the next five after the
send date.
- **Community contributions:** PRs merged in public `fleetdm` repos in
October by authors outside the `fleetdm` org, minus bots.

## Left out on purpose

- **"Windows: force standard account"** was in the planned section in
both September and October and hasn't shipped. It's not on the 4.95.0
board, so it isn't mentioned a third time.
- **Multiple versions of the same App Store app** is named in the 4.94.0
release article's title, but the article marks it as moved to 4.95. It's
listed under "Also on deck" instead of "shipped."
- **Amsterdam workshop (November 3):** past by the time this sends.
- **Fleet staff or contractors whose accounts aren't in the org:**
@TraiLynne and @thomcrowe. Both are confirmed in Fleet's Slack.
- **Other October content:** the warehouse inventory article and
Retriever guide, the PHP2Shell and eMudhra pieces, and every `industry
news` article. The routine doesn't feature that category.

<details>
<summary>Suggested <code>~/fleet-newsletters/contributors.tsv</code>
lines (append once confirmed)</summary>

```
TraiLynne	fleet	Trai Lynne Compton, Fleet staff (Slack); not an org member
thomcrowe	fleet	Thom Crowe, Fleet contractor (website); not an org member
```

</details>

<details>
<summary>Ledger append block: run only after this issue is
sent</summary>

`~/fleet-newsletters/ledger.jsonl` didn't exist before this issue.
Repeats were checked against the September and October issues in the
repo instead. This block creates the ledger and records every item in
this issue.

```bash
mkdir -p ~/fleet-newsletters && cat >> ~/fleet-newsletters/ledger.jsonl <<'EOF'
{"issue":"2026-11","section":"shipped","id":"4.93.0"}
{"issue":"2026-11","section":"shipped","id":"4.94.0"}
{"issue":"2026-11","section":"planned","id":"51599"}
{"issue":"2026-11","section":"planned","id":"39176"}
{"issue":"2026-11","section":"planned","id":"51979"}
{"issue":"2026-11","section":"planned","id":"53284"}
{"issue":"2026-11","section":"planned","id":"33062"}
{"issue":"2026-11","section":"planned","id":"52534"}
{"issue":"2026-11","section":"planned","id":"47904"}
{"issue":"2026-11","section":"events","id":"fleet-virtual-summit-2026"}
{"issue":"2026-11","section":"events","id":"2003719976388"}
{"issue":"2026-11","section":"events","id":"2003716644422"}
{"issue":"2026-11","section":"events","id":"2002266719658"}
{"issue":"2026-11","section":"events","id":"2002266872114"}
{"issue":"2026-11","section":"events","id":"2002267524064"}
{"issue":"2026-11","section":"articles","id":"apple-in-the-enterprise-2026"}
{"issue":"2026-11","section":"articles","id":"nvidia-gtc-2026"}
{"issue":"2026-11","section":"articles","id":"tailworm-what-to-do-about-tailscale-ssh-before-the-fix-ships"}
{"issue":"2026-11","section":"articles","id":"revert-a-bad-change-in-gitops"}
{"issue":"2026-11","section":"articles","id":"block-chrome-extensions"}
{"issue":"2026-11","section":"articles","id":"block-edge-extensions"}
{"issue":"2026-11","section":"articles","id":"block-firefox-extensions"}
{"issue":"2026-11","section":"articles","id":"block-safari-extensions"}
{"issue":"2026-11","section":"articles","id":"use-claude-code-with-fleet"}
{"issue":"2026-11","section":"articles","id":"roadmap-preview-october-2026"}
{"issue":"2026-11","section":"social","id":"7513481631123394560"}
{"issue":"2026-11","section":"community","id":"#50836"}
{"issue":"2026-11","section":"community","id":"#53407"}
{"issue":"2026-11","section":"community","id":"#53670"}
{"issue":"2026-11","section":"community","id":"#53768"}
{"issue":"2026-11","section":"community","id":"#53810"}
{"issue":"2026-11","section":"community","id":"#53824"}
{"issue":"2026-11","section":"community","id":"#54019"}
{"issue":"2026-11","section":"community","id":"#54181"}
{"issue":"2026-11","section":"community","id":"#54296"}
{"issue":"2026-11","section":"community","id":"#54411"}
{"issue":"2026-11","section":"community","id":"#54502"}
{"issue":"2026-11","section":"community","id":"#54509"}
{"issue":"2026-11","section":"community","id":"#54592"}
{"issue":"2026-11","section":"community","id":"#54685"}
{"issue":"2026-11","section":"community","id":"#54708"}
{"issue":"2026-11","section":"community","id":"#54726"}
{"issue":"2026-11","section":"community","id":"#54785"}
{"issue":"2026-11","section":"community","id":"#55056"}
{"issue":"2026-11","section":"community","id":"#55058"}
{"issue":"2026-11","section":"community","id":"#55072"}
{"issue":"2026-11","section":"community","id":"#55089"}
{"issue":"2026-11","section":"community","id":"#55097"}
{"issue":"2026-11","section":"community","id":"#55127"}
{"issue":"2026-11","section":"community","id":"#55249"}
{"issue":"2026-11","section":"community","id":"#55266"}
{"issue":"2026-11","section":"community","id":"#55353"}
{"issue":"2026-11","section":"community","id":"#55471"}
{"issue":"2026-11","section":"community","id":"#55492"}
{"issue":"2026-11","section":"community","id":"#55547"}
{"issue":"2026-11","section":"community","id":"#55841"}
{"issue":"2026-11","section":"community","id":"#55900"}
{"issue":"2026-11","section":"community","id":"#55903"}
{"issue":"2026-11","section":"community","id":"#55946"}
{"issue":"2026-11","section":"community","id":"#56072"}
{"issue":"2026-11","section":"community","id":"#56085"}
{"issue":"2026-11","section":"community","id":"#56148"}
{"issue":"2026-11","section":"community","id":"#56214"}
{"issue":"2026-11","section":"community","id":"#56266"}
{"issue":"2026-11","section":"community","id":"#56287"}
{"issue":"2026-11","section":"community","id":"#56376"}
{"issue":"2026-11","section":"community","id":"#56403"}
{"issue":"2026-11","section":"community","id":"#56486"}
{"issue":"2026-11","section":"community","id":"#56498"}
{"issue":"2026-11","section":"community","id":"#56575"}
{"issue":"2026-11","section":"community","id":"#56596"}
{"issue":"2026-11","section":"community","id":"#56609"}
{"issue":"2026-11","section":"community","id":"#56657"}
{"issue":"2026-11","section":"community","id":"#56708"}
{"issue":"2026-11","section":"community","id":"#56719"}
{"issue":"2026-11","section":"community","id":"#56983"}
{"issue":"2026-11","section":"community","id":"#56984"}
{"issue":"2026-11","section":"community","id":"#56985"}
EOF
```

</details>

## Testing

- [x] Confirmed the markdown passes the website build's metadata checks:
required meta tags, ISO `publishedOn`, description at 139 of 150
characters, `category` set to `newsletter`, H1 matching `articleTitle`,
and no Vue-template braces.
- [x] Verified all 54 fleetdm.com, GitHub, and Eventbrite links return
200. LinkedIn returns 999 to automated requests, so the profile links
come from the handbook and the post link was opened in a browser.
- [x] Checked the copy against Fleet's content style: no em dashes,
sentence-case headings, Oxford commas, and Fleet Premium labels carried
through from the release articles.
- [ ] QA'd all new/changed functionality manually

## AI

**AI:** Claude Code (claude-opus-5-5)

---------

Co-authored-by: robinedev <aubedev@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possible memory leak: C.CString(appPath) is never freed in getAppIcon

2 participants