[release-1.11] malloc: use jl_get_current_task to fix null check #58202
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.
Since 1.11.5 we are getting crashes from OpenMP threads of an external library which uses GMP numbers. This did not happen on 1.11.4. Version 1.12 and nightly are also unaffected.
Attaching
gdb
shows that the task struct is an invalid pointer (but notNULL
):This value seems to come from the
jl_current_task
macrowhich doesn't check whether
jl_get_pgcstack()
returnsNULL
for foreign threads. Two lines further down is a check forct != NULL
but this cannot happen sincecontainer_of
will just subtract a fixed offset from a NULL-pointer.julia/src/gc.c
Lines 4122 to 4124 in 2d89891
I changed the relevant two lines to use
jl_get_current_task()
which will properly returnNULL
ifjl_get_pgcstack()
returnsNULL
. This also aligns it with the current master:julia/src/gc-stock.c
Lines 3741 to 3742 in 16eca6e
This was probably introduced during the backport in #57880, @gbaraldi.
Note that this PR targets
release-1.11
, not sure if this is correct but there is nobackports-release-1.11
branch right now.cc: @lgoettgens
x-ref: oscar-system/Oscar.jl#4806