Repository navigation
fix: native rust fix for HAMT/ContextVar crash [backport 4.9] - #18709
Merged
Merged
Conversation
KowalskiThomas
requested review from
P403n1x87 and
rachelyangdog
and removed request for
a team
June 23, 2026 14:38
Codeowners resolved as |
Contributor
🎉 All green!🧪 All tests passed 🔗 Commit SHA: 993928d | Docs | Datadog PR Page | Give us feedback! |
BenchmarksBenchmark execution time: 2026-06-23 16:32:08 Comparing candidate commit 993928d in PR branch Found 0 performance improvements and 5 performance regressions! Performance is the same for 608 metrics, 9 unstable metrics. scenario:iastaspects-lstrip_aspect
scenario:iastaspects-translate_aspect
scenario:iastaspectsospath-ospathbasename_aspect
scenario:span-start
scenario:telemetryaddmetric-1-count-metric-1-times
|
Route ContextVar activation through a native helper on CPython < 3.12 to pin context storage across PyContextVar_Set and avoid a rare HAMT/GC SEGV_MAPERR crash. Backport of kowalski/fix-fancy-rust-fix-for-hamt-crash.
KowalskiThomas
force-pushed
the
kowalski/backport-18599-to-4.9
branch
from
June 23, 2026 15:57
0291d00 to
993928d
Compare
brettlangdon
approved these changes
Jun 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of PR #18599 (branch
kowalski/fix-fancy-rust-fix-for-hamt-crash) to branch 4.9.Description
This is an attempt to fix a customer-reported crash (Jira).
ContextVar-related crash: fix(internal): crash in ContextVar #17407This fix addresses the issue in a sort of makeshift way like the CPython upstream fix would. Since we can't bump reference counts directly from CPython, the PR adds a Rust helper which takes care of it. Not great, not terrible.
Note the bug only happens in versions prior to 3.12 (which made significant changes to the GC and doesn't trigger that HAMT crash anymore), so the fix is gated to them.
Notes on conflict resolution
Applied manually to the release branch.
contextvar::register_contextvaris wired into each branch'ssrc/native/lib.rslayout (4.8 usesutilsinstead ofddtrace_utils; 4.11 registers afterevent_hub).