RFC: codegen: root the result of `unsafe_pointer_to_objref` #65207
All Vouch review confidence checks passed
Residual risk 0.11 = Change Risk (0.50) × (1 − Review Confidence (0.77)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 179 lines diff across 12 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.71 · 2 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.311
Real PR Conversation Timeline
4 items
Does it? I was pretty sure GC placement treats that as the definition of an unnecessary object to track (for our standard idiom for constants that don't need tracking)
Approved
Approved these changes.
The docs are very Claudish
vtjnash
Keno
unsafe_pointer_to_objrefwas lowered to an address space cast of the pointer. GC root placement treats such a cast as the definition of a tracked value, but it only sees the cast where the optimizer left it, and a cast has no effects that would keep it in place. InstCombine, for instance, turns aselectof two casts into a cast of theselect. When that moves the cast past a safepoint, the object is not rooted there, although the reference was created before it. An object that is only kept alive untilunsafe_pointer_to_objrefreturns, for example by aGC.@preservearound the call, could thus be freed while the returned reference was still in use.Lower it to a call of a new
julia.pointer_to_objrefintrinsic instead, which GC root placement turns into the cast once the roots are placed. The intrinsic is not speculatable and is declared to modify memory that only the runtime can access, so that the optimizer leaves the call where it is relative to safepoints and control flow.This came up in the review of #65198.
Assisted-by: Claude Code (Claude Fable 5.2)