Skip to content

Commit

Permalink
Null out lastt->ptls after setting current task (pgcstack)
Browse files Browse the repository at this point in the history
This makes it difficult for `usr2_handler` to observe null ptls.
  • Loading branch information
tkf committed Nov 11, 2021
1 parent e001bc7 commit 17a70d2
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,18 +424,17 @@ static void ctx_switch(jl_task_t *lastt)
else
#endif
*pt = NULL; // can't fail after here: clear the gc-root for the target task now
lastt->ptls = NULL;
}

// set up global state for new task and clear global state for old task
t->ptls = ptls;
jl_atomic_store_relaxed(&ptls->current_task, t);
JL_GC_PROMISE_ROOTED(t);
jl_set_pgcstack(&t->gcstack);
lastt->ptls = NULL;
#ifdef MIGRATE_TASKS
ptls->previous_task = lastt;
#endif
jl_set_pgcstack(&t->gcstack);

if (t->started) {
#ifdef COPY_STACKS
Expand Down

0 comments on commit 17a70d2

Please sign in to comment.