Skip to content

Commit

Permalink
Replace unconditional store with cmpswap to avoid deadlocking in jl_f…
Browse files Browse the repository at this point in the history
…ptr_wait_for_compiled_addr (#56444)

That unconditional store could overwrite the actual compiled code in
that pointer, so make it a cmpswap
  • Loading branch information
gbaraldi authored Nov 4, 2024
1 parent 66c50ac commit 36f06b8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10166,7 +10166,8 @@ jl_llvm_functions_t jl_emit_codeinst(
!(params.imaging_mode || jl_options.incremental)) { // don't delete code when generating a precompile file
// Never end up in a situation where the codeinst has no invoke, but also no source, so we never fall
// through the cracks of SOURCE_MODE_ABI.
jl_atomic_store_release(&codeinst->invoke, jl_fptr_wait_for_compiled_addr);
jl_callptr_t expected = NULL;
jl_atomic_cmpswap_relaxed(&codeinst->invoke, &expected, jl_fptr_wait_for_compiled_addr);
jl_atomic_store_release(&codeinst->inferred, jl_nothing);
}
}
Expand Down

0 comments on commit 36f06b8

Please sign in to comment.