Skip to content

Commit 3a1d13a

Browse files
committed
Make Base.disable_library_threading_hooks ephemeral to the process
This prevents accidentally registering hooks during the sysimage build that would persist to run-time, unlike what happens when building in a pkgimage.
1 parent d268106 commit 3a1d13a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

base/initdefs.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,13 @@ end
494494
## hook for disabling threaded libraries ##
495495

496496
library_threading_enabled::Bool = true
497-
const disable_library_threading_hooks = []
497+
498+
# Base.OncePerProcess ensures that any registered hooks do not outlive the session.
499+
# (even if they are registered during the sysimage build process by top-level code)
500+
const disable_library_threading_hooks = Base.OncePerProcess(Vector{Any})
498501

499502
function at_disable_library_threading(f)
500-
push!(disable_library_threading_hooks, f)
503+
push!(disable_library_threading_hooks(), f)
501504
if !library_threading_enabled
502505
disable_library_threading()
503506
end
@@ -506,8 +509,8 @@ end
506509

507510
function disable_library_threading()
508511
global library_threading_enabled = false
509-
while !isempty(disable_library_threading_hooks)
510-
f = pop!(disable_library_threading_hooks)
512+
while !isempty(disable_library_threading_hooks())
513+
f = pop!(disable_library_threading_hooks())
511514
try
512515
f()
513516
catch err

0 commit comments

Comments
 (0)