Skip to content

fix(dictionary): survive a failed root-table calloc (PROF-16703) - #1074

Open
zhengyu123 wants to merge 4 commits into
mainfrom
fix/PROF-16703-dictionary-root-calloc
Open

zhengyu123 wants to merge 4 commits into
mainfrom
fix/PROF-16703-dictionary-root-calloc

Conversation

@zhengyu123

@zhengyu123 zhengyu123 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?:
Dictionary(int) no longer writes through a NULL _table when the root-table calloc fails. A failed construction leaves an empty dictionary:

  • lookup() returns its sentinel, the same signal as a failed insert, so bounded_lookup() and check() follow.
  • collect() and clear() do nothing, and ~Dictionary() returns early.
  • No NativeMem or DICTIONARY_* counter is touched. The counters are shared by id with live sibling dictionaries (Lookup builds _packages and _symbols, both id 0).

Motivation:
PROF-16703. Same defect class as PROF-16692 / #1005, which fixed the insert paths only. The constructor runs on every dump.

Additional Notes:

  • Design choice: keep a nullable _table with NULL guards. Embedding the root table by value would remove the guards, but it moves about 6 KB into the object. Rejected here to keep the change small.
  • clear() does not retry the root allocation. Lookup builds its dictionaries per dump, so a failed one is short-lived.
  • Human review: recommended. The change is small, but it touches the allocation-failure path and counters shared across dictionaries.
  • Review: Sphinx (standard effort) on the first commit gave 7 Low findings, 4 fixed; the other 3 are the two design points above and one partly addressed test finding. Three follow-up reviews of the fix commits ended with no open findings.

How to test the change?:
New gtests in dictionary_ut.cpp, using a test-only flag that forces the root calloc to fail:

  • an empty, safe dictionary after a root failure, including the NativeMem balance;
  • SymbolDictionary resolving to its reserved ids, with the entry contents asserted;
  • recovery on the next construction;
  • the shared counters left unchanged next to a live sibling (fails if the failure branch writes them).

Results:

  • Before the fix, a reproducer test of the same failure died with signal 11 (macOS arm64 debug).
  • qualityChecks and :ddprof-lib:gtestDebug, macOS arm64, at 937c76f99: 0 failures. dictionary_ut passes 18 tests at the final head.
  • dictionary_ut in aarch64 containers (glibc ASan, glibc debug, musl debug) at 72dd2a65f: exit 0 each. Later commits are test-only and were not re-run there.

For Datadog employees:

  • If this PR touches code that signs or publishes builds or packages, or handles
    credentials of any kind, I've requested a security review (run the dd:platform-security-review
    skill, or file a request via the PSEC review form).
    bewaire also runs automatically on every PR.
  • This PR doesn't touch any of that.
  • JIRA: PROF-16703

Unsure? Have a question? Request a review!

🤖 Generated with Claude Code

zhengyu123 and others added 4 commits November 30, 2026 15:18
Dictionary(int) wrote _table->base_index after an unchecked calloc. A
failed allocation now leaves an empty dictionary: lookup returns its
sentinel, collect and clear do nothing, and the destructor skips the
accounting the constructor never recorded.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A failed constructor now touches no DICTIONARY_* counter, which are shared
by id with live sibling dictionaries. The tests also assert the reserved
SymbolDictionary entries and the bounded insert path after recovery.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Adds a sibling-dictionary counter test and drops a bounded_lookup check
that could not detect the regression it named.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ewrite

The sibling now grows overflow tables, so its counters differ from the values
a failed constructor would write if it set them as the success path does.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@zhengyu123
zhengyu123 requested a review from a team as a code owner November 30, 2026 20:53
@zhengyu123 zhengyu123 added the human_review:recommended Human review recommended — see PR description label Nov 30, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-30T20:56:22.371957Z 558e32d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@zhengyu123

Copy link
Copy Markdown
Contributor Author

@DataDog review

@zhengyu123 zhengyu123 added the dog-sitter Actively watched by babysit-pr: fixes pushed through the repo gates label Nov 30, 2026
@zhengyu123

zhengyu123 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor Author

🐶 babysit-pr was watching this PR — CI breakages and mechanical findings are fixed and pushed automatically; design decisions are always brought to you.

This run
  • 20:54 · started · CI on head 558e32d in progress
  • 21:05 · Bits · BITS CODE REVIEW PASS on 558e32d, no inline threads
  • 21:35 · CI red · dd-gitlab/post-pr-comment and dd-gitlab/default-pipeline — dd-trace integration produced no results; GitLab not retryable from here, other open PRs show the same failure
  • 21:36 · stopped · no commits pushed, 0 findings, 0 threads, bits_triggered 558e32d, bits_rerequested none

✅ stopped 21:36 UTC · all GitHub checks and Bits green; dd-gitlab/post-pr-comment failed (integration tests produced no results), needs a human GitLab retry

@datadog-prod-us1-4 datadog-prod-us1-4 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bits Code Review: PASS

More details

The null-root guards preserve lookup sentinels and leave native-memory accounting and shared dictionary counters untouched after allocation failure. The completed static review found no actionable defect.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 558e32d

@datadog-prod-us1-4 datadog-prod-us1-4 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bits Code Review: PASS

More details

Failed root allocation leaves an empty dictionary with preserved lookup sentinels and symbol fallbacks, while cleanup avoids changing shared accounting. The static reviewer reported no actionable defects.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 558e32d

@datadog-prod-us1-4

datadog-prod-us1-4 Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

❌ Errors

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 31 Pipeline jobs failed

DataDog/java-profiler | integration-test-arm64-glibc: [hotspot, 11] — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

DataDog/java-profiler | integration-test-arm64-glibc: [hotspot, 17] — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

DataDog/java-profiler | integration-test-arm64-glibc: [hotspot, 21] — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

View all 31 failed jobs.

ℹ️ Info

🔁 Datadog re-ran get-versions after it failed. The re-run passed. View in Datadog

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 558e32d | Docs | View more details | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Memory overhead check: ✅ within budget

Profiler 558e32d62, pipeline. Budget: utils/memcheck/budget.txt. NMT and /proc values are profiled minus no-profiler runs on the same runner.

scenario metric value Δ since budget set limit headroom
allocs native_mem_live_bytes 21.72 MiB +33 KiB 21.95 MiB 233 KiB ok
allocs native_mem_max_bytes 22.97 MiB +19 KiB 23.20 MiB 237 KiB ok
allocs nmt.class 303 KiB +6 KiB 563 KiB 261 KiB ok
allocs nmt.internal 370 KiB +1 KiB 666 KiB 296 KiB ok
classesM native_mem_live_bytes (coverage-corrected) 23.28 MiB +3 KiB 23.55 MiB 274 KiB ok
classesM native_mem_max_bytes (coverage-corrected) 25.21 MiB +16 KiB 25.45 MiB 250 KiB ok
classesM nmt.class 2.94 MiB −0 KiB 3.20 MiB 266 KiB ok
classesM nmt.internal 3.20 MiB +5 KiB 3.50 MiB 302 KiB ok
mixed native_mem_live_bytes 23.15 MiB −2 KiB 23.45 MiB 309 KiB ok
mixed native_mem_max_bytes 40.76 MiB +44 KiB 41.00 MiB 242 KiB ok
mixed nmt.class 302 KiB −5 KiB 563 KiB 261 KiB ok
mixed nmt.internal 406 KiB −3 KiB 717 KiB 310 KiB ok
threads native_mem_live_bytes 19.08 MiB −8 KiB 19.35 MiB 274 KiB ok
threads native_mem_max_bytes 20.10 MiB −14 KiB 20.40 MiB 311 KiB ok
threads nmt.class 114 KiB +1 KiB 410 KiB 296 KiB ok
threads nmt.internal 161 KiB −3 KiB 461 KiB 300 KiB ok
traces native_mem_live_bytes 20.24 MiB +15 KiB 20.50 MiB 261 KiB ok
traces native_mem_max_bytes 21.43 MiB +24 KiB 21.70 MiB 273 KiB ok
traces nmt.class 470 KiB −1 KiB 768 KiB 298 KiB ok
traces nmt.internal 611 KiB −4 KiB 870 KiB 260 KiB ok

✅ nmt.tracing absent in every scenario.

Not budgeted (too noisy on shared runners)
scenario nmt.code nmt.gc nmt.total proc.VmRSS proc.RssAnon
allocs 1.67 MiB 5 KiB 2.77 MiB 32.50 MiB 28.08 MiB
classesM 4.61 MiB 31 KiB 11.92 MiB 41.95 MiB 37.34 MiB
mixed 1.62 MiB 3 KiB 2.77 MiB 31.53 MiB 26.82 MiB
threads 6 KiB 0 KiB 547 KiB 24.77 MiB 19.70 MiB
traces 4.55 MiB 6 KiB 6.18 MiB 22.35 MiB 17.82 MiB

@dd-octo-sts

dd-octo-sts Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

CI Test Results

Run: #46511117485 | Commit: 9d5611c | Duration: 22m 40s (longest job)

✅ All 32 test jobs passed

Status Overview

JDK glibc-aarch64/debug glibc-amd64/debug musl-aarch64/debug musl-amd64/debug
8 - ✅ - -
8-ibm - ✅ - -
8-j9 ✅ ✅ - -
8-librca - - ✅ ✅
8-orcl - ✅ - -
11 - ✅ - -
11-j9 ✅ ✅ - -
11-librca - - ✅ ✅
17 ✅ ✅ - -
17-graal ✅ ✅ - -
17-j9 ✅ ✅ - -
17-librca - - ✅ ✅
21 ✅ ✅ - -
21-graal ✅ ✅ - -
21-librca - - ✅ ✅
25 ✅ ✅ - -
25-graal ✅ ✅ - -
25-librca - - ✅ ✅

Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled

Summary: Total: 32 | Passed: 32 | Failed: 0


Updated: 2026-11-30 21:20:52 UTC

@dd-octo-sts

dd-octo-sts Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

🚨 Integration tests could not run — no results were produced

No applicable configuration in integration-test-results produced a pass/fail result.
Check the pipeline logs for setup or validation failures.

👷 Pipeline · 📦 558e32d6

10 not applicable (not scheduled): musl-x64-openj9, musl-arm64-openj9. OpenJ9 requires glibc; upstream publishes no musl runtime.

@zhengyu123 zhengyu123 removed the dog-sitter Actively watched by babysit-pr: fixes pushed through the repo gates label Nov 30, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

human_review:recommended Human review recommended — see PR description

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant