Skip to content

Commit d9ba0a0

Browse files
vtjnashvchuravyJeffBezanson
authored andcommitted
add wb_back on all task switch paths (JuliaLang#60617)
Since this task's stack or scope field could have been modified after it was marked by an incremental collection (and not just for copy stacks), move the barrier back unconditionally here. --------- Co-authored-by: Valentin Churavy <[email protected]> Co-authored-by: Jeff Bezanson <[email protected]>
1 parent db74dc0 commit d9ba0a0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/task.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,6 @@ static void NOINLINE save_stack(jl_ptls_t ptls, jl_task_t *lastt, jl_task_t **pt
203203
lastt->ctx.copy_stack = nb;
204204
lastt->sticky = 1;
205205
memcpy_stack_a16((uint64_t*)buf, (uint64_t*)frame_addr, nb);
206-
// this task's stack could have been modified after
207-
// it was marked by an incremental collection
208-
// move the barrier back instead of walking it again here
209-
jl_gc_wb_back(lastt);
210206
}
211207

212208
JL_NO_ASAN static void NOINLINE JL_NORETURN restore_stack(jl_ucontext_t *t, jl_ptls_t ptls, char *p)
@@ -504,6 +500,12 @@ JL_NO_ASAN static void ctx_switch(jl_task_t *lastt)
504500
lastt->ctx.ctx = &lasttstate.ctx;
505501
}
506502
}
503+
// this task's stack or scope field could have been modified after
504+
// it was marked by an incremental collection
505+
// move the barrier back instead of walking the shadow stack again here to check if that is required
506+
// even if killed (dropping the stack) and just the scope field matters,
507+
// let the gc figure that out next time it does a quick mark
508+
jl_gc_wb_back(lastt);
507509

508510
// set up global state for new task and clear global state for old task
509511
t->ptls = ptls;

0 commit comments

Comments
 (0)