Skip to content

Commit 1d15e9f

Browse files
don't free regex objects in exit-time finalizer calls
1 parent 8561cc3 commit 1d15e9f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

base/regex.jl

+6-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ mutable struct Regex <: AbstractPattern
3939
end
4040
re = compile(new(pattern, compile_options, match_options, C_NULL))
4141
finalizer(re) do re
42-
re.regex == C_NULL || PCRE.free_re(re.regex)
42+
# don't free during exit because tasks may still be running and
43+
# using it. Issue #57817
44+
during_exit = Base._atexit_hooks_finished
45+
if re.regex != C_NULL && !during_exit
46+
PCRE.free_re(re.regex)
47+
end
4348
end
4449
re
4550
end

0 commit comments

Comments
 (0)