-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SnoopPrecompile segfault regression with IOCapture.jl #48837
Comments
Does this on 1.9 as well? |
Yep, checked, the |
I got an
where (rr) call jl_(m)
(::Type{Base.IOContext{IO_t} where IO_t<:IO})(IO, Pair{A, B} where B where A)
(rr) call jl_(m->roots)
Array{Any, (44,)}[
:unwrapcontext,
:ImmutableDict,
:IOContext,
Base.ImmutableDict{Symbol, Any},
Base.ImmutableDict{Symbol, Any}(parent=#<null>, key=#<null>, value=#<null>),
Base.IOContext{Base.GenericIOBuffer{Array{UInt8, 1}}},
:io,
:dict,
Base.GenericIOBuffer{Array{UInt8, 1}},
Tuple{Symbol},
Tuple{Expr, Expr},
Tuple{Expr},
Tuple{Base.OneTo{Int64}},
NTuple{5, Expr},
Base.Dict{Symbol, Any},
Tuple{Symbol, Any},
Tuple{Int64},
Tuple{Symbol, Symbol, Expr},
Tuple{Symbol, Expr},
Tuple{Expr, Expr, Expr},
NTuple{4, Expr},
NTuple{4, Symbol},
Tuple{Symbol, Symbol, Symbol},
Base.IOContext{Core.CoreSTDOUT},
Core.CoreSTDOUT,
Char,
get_have_color() from get_have_color(),
:get_have_color,
Base.ImmutableDict{Symbol, Any}(parent=Base.ImmutableDict{Symbol, Any}(parent=#<null>, key=#<null>, value=#<null>), key=:color, value=true),
Base.IOContext{Base.TTY},
Tuple{String, Int64},
Symbol("ttyhascolor.jl"),
Base.TTY,
Base.Dict{String, String},
Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}},
Tuple{Int64, Int64},
Base.Dict{String, Base.VersionNumber},
Base.Set{String},
Pkg.REPLMode.Option,
Pkg.REPLMode.PackageIdentifier,
Pkg.REPLMode.Rev,
Pkg.REPLMode.Subdir,
Pkg.REPLMode.VersionToken,
Array{Int64, 2}]
(rr) call jl_(m->root_blocks)
#<null> The puzzling part is why it's referencing a root that isn't there. |
OK, I have a clearer understanding of what's happening: during the call to (::Type{Base.IOContext{IO_t} where IO_t<:IO})(Base.IOStream, Pair{Symbol, Bool}) from (::Type{Base.IOContext{IO_t} where IO_t<:IO})(IO, Pair{A, B} where B where A) During So the fundamental issue seems to be that roots that get added by sysimg I'm not sure of the right way to fix it. I had high hopes for diff --git a/src/init.c b/src/init.c
index 0651d3b274..cac7ac40e5 100644
--- a/src/init.c
+++ b/src/init.c
@@ -864,8 +864,13 @@ static NOINLINE void _finish_julia_init(JL_IMAGE_SEARCH rel, jl_ptls_t ptls, jl_
jl_module_init_order = NULL;
int i, l = jl_array_len(init_order);
for (i = 0; i < l; i++) {
- jl_value_t *mod = jl_array_ptr_ref(init_order, i);
- jl_module_run_initializer((jl_module_t*)mod);
+ jl_module_t *mod = (jl_module_t*)jl_array_ptr_ref(init_order, i);
+ // #48837: it is possible to have the __init__ methods add roots,
+ // which get referenced when compressing CodeInstances.
+ // We need to make sure they get marked with the correct key.
+ jl_precompile_toplevel_module = mod;
+ jl_module_run_initializer(mod);
+ jl_precompile_toplevel_module = NULL;
}
JL_GC_POP();
} but that's only a partial fix: the problem seems to be that we don't recreate the same roots in the test process, and so in a debug build we fail at Line 1248 in 48b4caa
key after writing the sysimg, they aren't cached.
However, there may be an easy solution. I'm testing it locally, but if it appears promising, there's a PR coming. |
I didn't test it, but I think #48875 wasn't supposed to fix it? |
That isn't what triggered the close (though it was a close mistake to happen) |
It was #48882, and that indeed fixes it. |
Ah, sorry, I didn't notice the other PR. In any case, I can also confirm that it fixed the Documenter issue 🎉 Thank you for a speedy fix! |
I don't know if this is a SnoopPrecompile (v1.0.3) issue or a Julia one, but adding the following call to IOCapture.jl:
Leads to a segfault with 1.10-DEV after e06a591 (#44527 and #47407, cc @timholy @vchuravy; 328dd57 is still good; thanks to @inkydragon for bisecting!).
Full segfault stacktrace
It can be reproduced by running a simple snippet in the test environment (I can't replicate it in the normal environment..).
I have pushed a branch with an MWE and doing
julia --project -e'using Pkg; Pkg.test()'
with Julia master should reproduce it.While the error is different, I think it's related to our precompile woes in Documenter where a SnoopPrecompile leads to a strange error after e06a591 that also traces back to IOCapture usage: JuliaDocs/Documenter.jl#2004
The text was updated successfully, but these errors were encountered: