You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do not hold a reference into the type memo across constructing a type (Covered by dco/Brian_Egge.md)
The previous commit rewrote unique_refc_map::get to return by value, and in
doing so held a reference into the map across mk(), the call that constructs
the type being interned. Constructing a type can intern the types it is made
of -- FixedArray and Array normalise their element type on the way in, for
one -- which re-enters the same map (the mutex is recursive for exactly this)
and can insert, and an insertion can rehash, and a rehash moves the entry the
reference pointed at. The write through it afterwards is a write to freed
memory. CI caught it: hobbes-test died with "double free or corruption" in
Compiler/ccInManyThreads on the clang-16 build, and only there, as
use-after-free does.
The original code looked the key up again after mk() for this reason, and
that is restored in a form that also keeps the first object if mk() interned
this very key on the way: look up, construct, look up again, keep whichever
entry is there.
While here, two of Copilot's review comments on morganstanley#552: the compaction in
net.C and prepl.C ran after the work and so was skipped when the work threw
-- and the failing input is the one that interned nothing but garbage. Both
sites now use a scope guard (CompactMTypeMemoryAtExit, in lang/type.H)
declared at the top of the request, so it runs on every way out: success,
the decode throwing, or the error write itself throwing on a dead peer. And
the reuse test in test/Matching.C now proves reuse rather than just its
correctness, by counting the ".regex." functions defined in a fresh compiler
as the same and a look-alike regex are compiled.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016rGT4C394qeh2DBQhqy3Tb
0 commit comments