Skip to content

Commit 75dba04

Browse files
authored
[LateLowerGCFrame] fix PlaceGCFrameReset for returns_twice (JuliaLang#57392)
Using the right variable here should help quite a bit with the random GC segfaults we have seen. We already have the tests for this, but it is quite hard to make them just complex enough to trigger reliably. Fixes JuliaLang#57333
1 parent 864d2bf commit 75dba04

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/codegen.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3232,7 +3232,6 @@ static bool slot_eq(jl_value_t *e, int sl)
32323232
// --- find volatile variables ---
32333233

32343234
// assigned in a try block and used outside that try block
3235-
32363235
static bool local_var_occurs(jl_value_t *e, int sl)
32373236
{
32383237
if (slot_eq(e, sl)) {
@@ -3272,13 +3271,13 @@ static bool have_try_block(jl_array_t *stmts)
32723271
return 0;
32733272
}
32743273

3275-
// conservative marking of all variables potentially used after a catch block that were assigned before it
3274+
// conservative marking of all variables potentially used after a catch block that were assigned after the try
32763275
static void mark_volatile_vars(jl_array_t *stmts, SmallVectorImpl<jl_varinfo_t> &slots, const std::set<int> &bbstarts)
32773276
{
32783277
if (!have_try_block(stmts))
32793278
return;
32803279
size_t slength = jl_array_dim0(stmts);
3281-
BitVector assigned_in_block(slots.size()); // conservatively only ignore slots assigned in the same basic block
3280+
BitVector assigned_in_block(slots.size()); // since we don't have domtree access, conservatively only ignore slots assigned in the same basic block
32823281
for (int j = 0; j < (int)slength; j++) {
32833282
if (bbstarts.count(j + 1))
32843283
assigned_in_block.reset();

src/llvm-late-gc-lowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2291,7 +2291,7 @@ void LateLowerGCFrame::PlaceGCFrameStores(State &S, unsigned MinColorRoot,
22912291
const LargeSparseBitVector &NowLive = S.LiveSets[*rit];
22922292
// reset slots which are no longer alive
22932293
for (int Idx : *LastLive) {
2294-
if (Idx >= PreAssignedColors && !HasBitSet(NowLive, Idx)) {
2294+
if (Colors[Idx] >= PreAssignedColors && !HasBitSet(NowLive, Idx)) {
22952295
PlaceGCFrameReset(S, Idx, MinColorRoot, Colors, GCFrame,
22962296
S.ReverseSafepointNumbering[*rit]);
22972297
}

0 commit comments

Comments
 (0)