Skip to content

Local names linking fixes#61165

Merged
topolarity merged 6 commits intoJuliaLang:masterfrom
xal-0:local-names-linking-fixes
Feb 26, 2026
Merged

Local names linking fixes#61165
topolarity merged 6 commits intoJuliaLang:masterfrom
xal-0:local-names-linking-fixes

Conversation

@xal-0
Copy link
Copy Markdown
Member

@xal-0 xal-0 commented Feb 26, 2026

The merging of #60031 revealed a few remaining multithreading issues with local names linking (https://buildkite.com/julialang/julia-master/builds/55081/steps/canvas?jid=019c9584-a2fa-4ddc-bc7e-95ee729211a0&tab=output).

This PR has a series of commits addressing these issues and making us a little more eager to crash with a useful message in situations that would otherwise result in a deadlock in JuliaTaskDispatcher:

  • We return as soon as possible from JLMaterializationUnit::materialize after calling MaterializationResponsibility::failMaterialization.
  • When an ORC lookup fails in publishCIs, call abort() instead of potentially deadlocking.

Two concurrency issues are fixed. The first is that there was a window of time during which a CodeInstance added to the JIT via jl_emit_codeinst_to_jit had invoke == jl_fptr_wait_for_compiled_addr, but did not have ORC symbols set up in JuliaOJIT::CISymbols. We solve this by taking the lock before setting up the ORC symbols, skipping any CodeInstances where another thread beat us to the punch in setting invoke.

I suspect the second issue is the one that was causing rare CI failures. We had a data race on the InFlight counter for JLJITLinkMemoryManager, which, if decremented below zero, would cause the FinalizedCallbacks to never fire. This manifests as deadlocks in JuliaTaskDispatcher, since those symbols will be stuck in the SymbolState::Resolved state forever.

If another thread observes jl_fptr_wait_for_compiled_addr after we've written it
to invoke, but before we have put ORC symbols for this CodeInstance in
CISymbols, it's possible for the publishCIs call to fail.  Avoid this by writing
jl_fptr_wait_for_compiled_addr while holding the LinkerMutex (all access to
CISymbols is protected by this mutex).
We enter a GC-safe region inside the JuliaTaskDispatcher now, instead.
@xal-0 xal-0 added the bugfix This change fixes an existing bug label Feb 26, 2026
@topolarity
Copy link
Copy Markdown
Member

Let's merge this to get CI green again 👍

Thanks @xal-0

@topolarity topolarity merged commit 248531f into JuliaLang:master Feb 26, 2026
5 of 9 checks passed
@xal-0 xal-0 deleted the local-names-linking-fixes branch February 26, 2026 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix This change fixes an existing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants