Fix segfault while profiling multitasking #42973
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In 1.8-DEV (2ece1cd), the following script segfaults
This seems to occur essentially because
SIGUSR2
handler can observejl_get_current_task()->ptls == NULL
. This patch simply adds a null check in the handler.I think the segfault is not unexpected since
lastt->ptls = NULL
andjl_set_pgcstack(&t->gcstack)
doesn't happen atomically in the task switch:julia/src/task.c
Lines 434 to 438 in 2ece1cd
The above script still doesn't work in 1.8-DEV due to (presumably) some deadlock issue. But I think this patch can already be applied.
I can reproduce this in 1.7.0-rc2.31 (75961b2) so this needs to be backported. (Interestingly, I couldn't get the same issue in 1.7.0-rc1.63 e888fb8; So the bug may be introduced or surfaced between this window.)