Skip to content

Commit

Permalink
Fix jl_new_task to avoid allocating stack twice
Browse files Browse the repository at this point in the history
If the user requested dedicated stack of a certain size, then `jl_new_task`
immediately allocates the stack by invoking `jl_alloc_fiber`.

However, it also later nulls `t->stkbuf`. As a result, `ctx_switch` invokes
`jl_alloc_fiber` *again* to allocate another stack.
  • Loading branch information
fingolfin committed Jan 5, 2021
1 parent 399f8ba commit 67d48e7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ JL_DLLEXPORT jl_task_t *jl_new_task(jl_function_t *start, jl_value_t *completion
else {
t->bufsz = JL_STACK_SIZE;
}
t->stkbuf = NULL;
}
else {
// user requested dedicated stack of a certain size
Expand All @@ -701,7 +702,6 @@ JL_DLLEXPORT jl_task_t *jl_new_task(jl_function_t *start, jl_value_t *completion
t->sticky = 1;
t->gcstack = NULL;
t->excstack = NULL;
t->stkbuf = NULL;
t->started = 0;
t->prio = -1;
t->tid = -1;
Expand Down

0 comments on commit 67d48e7

Please sign in to comment.