Repository navigation
fix(v2/linux,darwin): plug Calloc leak caused by value receivers - #6083
Conversation
String appended each C.CString to a copy of the receiver, so the caller's pool stayed nil and Free had nothing to release. Every string allocated for dialogs, menus, single instance and window setup leaked. Return a pointer from NewCalloc and use pointer receivers, matching v3. Fixes wailsapp#6059 Fixes wailsapp#6058
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. WalkthroughThe Darwin and Linux ChangesCalloc lifecycle
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to Darwin and Linux C-string allocations are now retained by the shared allocator and released during cleanup, fixing the reported frontend memory leak with no remaining merge-blocking risk. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description explains the bug, affected platforms, implementation, linked issues, and call-site compatibility. It does not include the required change type, testing details, test configuration, or checklist responses. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. A rabbit found strings in a C-shaped haystack Comment |
leaanthony
left a comment
There was a problem hiding this comment.
Reviewed the allocator change and native string lifetimes. Pointer receivers fix allocation tracking and deferred cleanup on both v2 platforms; the changelog entry is included. Required checks pass. The equivalent v3 GTK4 and GTK3 fixes are already present from #5466.
… plug Calloc leak caused by value receivers
Batches this week's soaked, low-risk Dependabot updates into one tested PR. One update is excluded because it breaks Radar's MCP private-mount handshake. **Screening time:** 2026-09-23T09:42:55Z · **72h cutoff:** published at or before 2026-09-20T09:42:55Z. Ages are measured from the upstream publication time (npm registry / Go module proxy), not from when Dependabot opened the PR. ## Included (9) | PR | Dependency | Old → New | Published (UTC) | Soak | Risk conclusion | |---|---|---|---|---|---| | #1860 | github.com/cilium/cilium | 1.20.1 → 1.20.2 | 2026-09-15 18:52 | 7.6d | Radar imports only `api/v1/observer` + `api/v1/flow` (`internal/traffic/hubble.go`). Those generated files differ only in the protoc version comment. The release contains Hubble Relay/agent fixes that don't touch the client API. | | #1858 | google.golang.org/grpc | 1.83.2 → 1.84.0 | 2026-09-17 20:03 | 5.6d | Only used for the Hubble client (`grpc`, `credentials`, `credentials/insecure`). The one behavior change renames the `stats/otel` pick_first metrics, which Radar doesn't use. Also fixes a client that could stay stuck in IDLE after an RPC was canceled during stream creation. | | #1856 | github.com/wailsapp/wails/v2 | 2.15.0 → 2.16.0 | 2026-09-14 09:13 | 9.0d | The only v2 source change fixes a `Calloc` leak on darwin/linux: the value receiver becomes a pointer receiver, so `Free()` now actually frees. I checked for use-after-free: the ObjC side copies every string into an `NSString` (`safeInit`) synchronously before Go frees it. No v2.16.0 regressions reported upstream. | | #1854 | helm.sh/helm/v3 | 3.21.4 → 3.22.0 | 2026-09-09 22:21 | 13.5d | Upstream calls it "primarily dependency updates and k8s-io group to 0.37.0", which matches Radar's k8s 0.37.0. Also fixes the registry token scope for `helm push`. The last Helm 3 minor release. | | #1857 | @tanstack/react-query (+ query-core) | 5.102.8 → 5.103.1 | 2026-09-16 15:01 | 7.8d | #11502 changes filter matching: a filter key with trailing `undefined` no longer matches a shorter query key. I audited all 149 invalidate/remove/cancel/setQueriesData call sites. Radar's query keys are fixed-length (the only spread key, `workloadMetrics.ts`, is fixed-length too), so no invalidation changes. | | #1855 | @types/node | 26.2.0 → 26.6.2 | 2026-09-19 00:11 | 4.4d | Type-only change, covered by `make tsc`. Bumped in both `web/` and `packages/k8s-ui/`. | | #1861 | prettier | 3.9.5 → 3.9.8 | 2026-09-17 21:41 | 5.5d | Dev-only formatter (`npm run format`), not run in CI. Before/after check: 3.9.5 and 3.9.8 flag the identical set of 304 files in `web/src`, so formatting output is unchanged. | | #1859 | react-router-dom (+ react-router) | 7.18.3 → 7.18.4 | 2026-09-15 15:05 | 8.0d | Two fixes: RSC redirect escaping (Radar doesn't use RSC) and avoiding `startViewTransition` during hydration/revalidate. Radar doesn't use view transitions. | | #1862 | tailwind-merge | 3.6.0 → 3.7.0 | 2026-09-12 20:10 | 10.6d | Nothing in `web/src` or `packages/*/src` imports it. It's only declared as a peer/dev dependency, so the bundle doesn't change. | ## Excluded / held (1, left open) - **#1776 github.com/modelcontextprotocol/go-sdk 1.6.1 → 1.8.0** (excluded for risk). The PR's own CI fails `TestInvestigationHandlerAnnotatesRealToolCallWithoutChangingPublicContract` with `private mount handshake did not mark the scope connected` (`internal/mcp/server_investigation_test.go:253`). This is a real change in how the SDK's handshake behaves against Radar's investigation-scope mount, not flakiness. Adopting it needs a Radar source change, which should be a separate follow-up PR. ## Resolver movement beyond the PR targets - **npm resolver floated past two targets, now pinned back:** a plain lockfile refresh resolved `@tanstack/react-query`/`query-core` **5.103.2** (published 2026-09-21T09:33Z, under 72h) and `prettier` **3.9.9** (published 2026-09-23T06:31Z, about 3h). The lockfile is pinned to the soaked targets 5.103.1 and 3.9.8. - **npm transitive:** `undici-types` 8.3.0 → 8.9.0. It's required by `@types/[email protected]` (`~8.9.0`), is type-only, and was published 2026-07-24. - **Go, compiled graph (in go.mod):** `santhosh-tekuri/jsonschema/v6` 6.0.2 → 6.0.3 (2026-06-28, via Helm) and `genproto/googleapis/{api,rpc}` → `v0.0.0-20260706201446` (2026-07-06, via gRPC). All are well past 72h. - **Go, module-graph-only (in `go list -m all`, not in go.mod):** `cloud.google.com/go/auth` 0.20.0, `gax-go/v2` 2.22.0, `enterprise-certificate-proxy` 0.3.15, `google.golang.org/api` 0.278.0, `detectors/gcp` 1.34.0, `cilium/statedb` 0.8.4, `felixge/httpsnoop` 1.1.0, `go-shellwords` 1.0.14, `x/telemetry` 2026-06-25, `k8s.io/endpointslice` 0.36.4, `gateway-api/conformance` 1.6.2. `phayes/freeport` was dropped. All were published between 2026-04-06 and 2026-09-03. - **go.mod bookkeeping:** `go mod tidy` moves `google/jsonschema-go` and `opencontainers/go-digest` from `// indirect` to direct. `main` was already untidy here (Radar imports both directly), and every Dependabot Go PR showed the same change. Versions are unchanged. ## Verification - `go mod verify`: all modules verified - `make tsc`: pass - `make test` (`go test ./...`): pass, 41 packages ok - `pkg/` module `go test ./...`: pass - `web` vitest: 127 files / 1497 tests pass - `packages/k8s-ui` vitest: 199 files / 3841 pass, 1 skipped - `make build`: pass - `make desktop-binary` (Wails, darwin/arm64): pass. The app was launched and stayed up for 10s with no crash or signal, which exercises the changed window/menu string-free path. - Targeted `go test -count=1` for `internal/traffic` (Hubble/gRPC), `internal/helm`, `internal/cloudinstall`, `internal/mcp`: pass - Prettier before/after: identical drift set (304/304) - `git diff --check`: clean. The diff touches only `go.mod`, `go.sum`, `package-lock.json`, `web/package.json`, and `packages/k8s-ui/package.json`. - **Not verified:** the Linux/Windows desktop builds (Wails needs cgo and a GTK/WebView2 toolchain). The Wails fix also covers linux `window.go`, which frees after `gtk` calls that copy their string arguments. - **visual-test: skipped.** The runtime frontend changes are two patch-level fixes (react-router view transitions/RSC, react-query key matching) that don't affect how Radar renders anything, and tailwind-merge isn't imported. ## Upstream sources - grpc-go v1.84.0: https://github.com/grpc/grpc-go/releases/tag/v1.84.0 - Helm v3.22.0: https://github.com/helm/helm/releases/tag/v3.22.0 - Cilium v1.20.2: https://github.com/cilium/cilium/releases/tag/v1.20.2 - Wails v2.16.0 changelog: https://github.com/wailsapp/wails/blob/v2.16.0/website/src/pages/changelog.mdx (fix: wailsapp/wails#6083) - TanStack Query: https://github.com/TanStack/query/releases/tag/%40tanstack%2Fquery-core%405.103.0, https://github.com/TanStack/query/releases/tag/%40tanstack%2Fquery-core%405.103.1 - React Router 7.18.4: https://github.com/remix-run/react-router/blob/v7/CHANGELOG.md#v7184 - tailwind-merge 3.7.0: https://github.com/dcastil/tailwind-merge/releases/tag/tailwind-merge%403.7.0 - Prettier 3.9.6–3.9.8: https://github.com/prettier/prettier/blob/3.9.8/CHANGELOG.md Supersedes #1854, #1855, #1856, #1857, #1858, #1859, #1860, #1861, #1862 <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Dependency-only updates with explicit soak notes and broad test coverage; MCP SDK was held back due to a known handshake regression. > > **Overview** > Batches nine **soaked** dependency bumps into one PR after screening; **modelcontextprotocol/go-sdk** is intentionally **not** included because it breaks Radar’s MCP private-mount handshake. > > **Go:** bumps **cilium** (1.20.1→1.20.2), **grpc** (1.83.2→1.84.0), **Wails v2** (2.15.0→2.16.0), and **Helm v3** (3.21.4→3.22.0), plus transitive refreshes in `go.sum`. **`go mod tidy`** also promotes **`google/jsonschema-go`** and **`opencontainers/go-digest`** from indirect to **direct** `require` entries (versions unchanged). > > **Frontend:** bumps **@tanstack/react-query** (5.103.1), **@types/node** (26.6.2 in `web/` and `packages/k8s-ui/`), **prettier** (3.9.8), **react-router-dom** (7.18.4), and **tailwind-merge** (3.7.0), with matching **`package-lock.json`** updates. The lockfile pins soaked targets (e.g. not floating to newer query/prettier releases) and drops many `"peer": true` metadata flags on nested packages. > > No application source changes—only module manifests and lockfiles. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 04f558f. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
Calloc.StringandCalloc.Freein the v2 linux and darwin frontends take the receiver by value, soStringappends eachC.CStringto a copy of the pool that is dropped on return. The caller's pool stays nil,Freeiterates nothing, and every string allocated for dialogs, menus, single-instance messaging and window setup leaks. On darwindefer c.Free()even captures the empty copy up front.NewCallocnow returns a pointer and both methods use pointer receivers, the same shape v3 already has inlinux_cgo.go. Call sites keepc := NewCalloc(); defer c.Free()unchanged. The windows frontend has no cgo allocator and is unaffected. Changelog entry added under Unreleased.Fixes #6059
Fixes #6058
Summary by CodeRabbit
Bug Fixes
Documentation