Repository navigation
Delete CodeCache copy assignment instead of fixing its leak - #995
Conversation
CodeCache::operator= freed the blob array but not the blob name strings, so every assignment leaked them. Nothing assigns a CodeCache, so delete the operator rather than fix it. Declare it "= delete" so a future assignment fails to compile instead of falling back to a shallow copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Scan-Build Report
Bug Summary
Filter Results by FileReports
|
|||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
More details
Deleting the unused assignment operator removes the leaking ownership path while preserving copy construction. The static assertion guards against accidentally restoring copy assignment.
🤖 Bits Code Review · Commit 7391412
CI Test ResultsRun: #43504024551 | Commit:
Status Overview
Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled Summary: Total: 32 | Passed: 32 | Failed: 0 Updated: 2026-11-13 21:06:12 UTC |
What does this PR do?:
CodeCache::operator=as= deleteand removes its definition.static_assert(!std::is_copy_assignable<CodeCache>::value)tocodeCache_ut.cpp.Motivation:
CodeCache::operator=freed_blobsbut did not callNativeFunc::destroy()on each blob's_name, unlike~CodeCache(). Every assignment leaked the target's blob name strings.Nothing assigns a
CodeCache. A temporary= deleteprobe compiled the library and all gtest sources (macOS, debug) with no assignment found. A grep ofddprof-lib/srccovers the Linux-only sources the macOS build skips.Deleting the operator is safer than fixing it:
operator=, which double-frees_blobsand the names. Only thestd::atomic<bool> _publishedmember blocks that today.Additional Notes:
operator=. This PR deletes the operator instead, so its acceptance criteria about an ASan leak test do not apply.operator=), fixed by thestatic_assert./code-reviewmedium on the two fix commits: Low findings only. Open, not fixed:copyFrom()now has one caller, the copy constructor, and could be inlined.static_assertcould live incodeCache.h, so non-test builds check it too.codeCache.hfor the reason.How to test the change?:
gtestDebug_codeCache_utandgtestRelease_codeCache_ut: 11/11 passed in each (macOS arm64).:ddprof-lib:gtestDebug: 1153 tests passed, 0 failed (macOS arm64). Linux-only suites link no tests on macOS; CI covers them.static_assertfails the test build ifCodeCachebecomes copy-assignable again.For Datadog employees:
credentials of any kind, I've requested a security review (run the
dd:platform-security-reviewskill, or file a request via the PSEC review form).
bewairealso runs automatically on every PR.Unsure? Have a question? Request a review!
🤖 Generated with Claude Code