Allocate over-aligned types with their alignment in UniquePtr::new #8456
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.35) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.35 · 173 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
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.309
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #8456"
general
weight: 0.35
piscisaureus
This fixes
cxx::UniquePtr::newandcxx::SharedPtr::newallocating over-aligned types without their alignment.Both allocate through
new ::rust::MaybeUninit<T>in the generated bridge and then write the value from Rust.MaybeUninitdeclares a class-scopeoperator new(std::size_t)so that it can forward toT::operator newwhenThas one; that also hides the global aligned overload, so for aTwith extended alignment the fallback called plain::operator new(sz). The storage is then only guaranteed the default new alignment, and thedeletethatstd::unique_ptrorstd::shared_ptrruns later is the aligned one. workerd has no over-aligned trivial extern type, so nothing hits this today.detail::operator_newfallback passesstd::align_val_t(alignof(T))whenalignof(T)exceeds__STDCPP_DEFAULT_NEW_ALIGNMENT__, and is unchanged otherwise.Tests:
cxx_gen_testchecks the generated allocation, and the cxx test suite gets analignas(64)trivial extern type withtest_smart_ptr_new_over_aligned, which checks that sixteenUniquePtr::newand sixteenSharedPtr::newvalues are all aligned. tcmalloc happens to hand out 64-byte blocks on 64-byte boundaries, so without the fix that second test only fails under--config=asan, which reports the constructor call on a misaligned address; thecxx_gen_testcheck fails either way.