Skip to content
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

Segfault in jl_is_globally_rooted #56996

Open
maleadt opened this issue Jan 8, 2025 · 2 comments
Open

Segfault in jl_is_globally_rooted #56996

maleadt opened this issue Jan 8, 2025 · 2 comments
Assignees
Labels
regression Regression in behavior compared to a previous version
Milestone

Comments

@maleadt
Copy link
Member

maleadt commented Jan 8, 2025

As spotted on PkgEval in TestSetExtensions.jl: https://s3.amazonaws.com/julialang-reports/nanosoldier/pkgeval/by_date/2025-01/02/TestSetExtensions.primary.log

MWE:

using Test
struct ExtendedTestSet{T<:Test.AbstractTestSet} <: Test.AbstractTestSet
    wrapped::T
    ExtendedTestSet{T}(desc) where {T} = new(T(desc))
end
ExtendedTestSet(desc) = ExtendedTestSet{Test.DefaultTestSet}(desc)

let
    out_reader = @async read(out_rd, String)
    @testset ExtendedTestSet "errors" begin
        throw(ErrorException("This test is supposed to throw an error"))
     end
    ccall(:jl_generating_output, Cint, ())
end
[1879856] signal 11 (128): Segmentation fault
in expression starting at /home/maleadt/julia/wip.jl:8
jl_is_globally_rooted at /source/src/staticdata.c:2753
jl_as_global_root at /source/src/staticdata.c:2768
inst_datatype_inner at /source/src/jltypes.c:2275
jl_inst_arg_tuple_type at /source/src/jltypes.c:2498
arg_type_tuple at /source/src/gf.c:2388 [inlined]
jl_lookup_generic_ at /source/src/gf.c:3432 [inlined]
ijl_apply_generic at /source/src/gf.c:3490
macro expansion at /source/usr/share/julia/stdlib/v1.12/Test/src/Test.jl:1737 [inlined]
top-level scope at /home/maleadt/julia/wip.jl:11

Seems to relate to the Expr(:latestworld-if-toplevel). Bisected to #56509

@maleadt maleadt added the regression Regression in behavior compared to a previous version label Jan 8, 2025
@maleadt maleadt added this to the 1.12 milestone Jan 8, 2025
@vtjnash
Copy link
Member

vtjnash commented Jan 8, 2025

Also looks like it also happens in MatrixEquations tests.

We have an object allocated by a dynamic call to copy at

macro expansion at /home/vtjnash/julia1/usr/share/julia/stdlib/v1.12/Test/src/Test.jl:1756
(rr) p jl_(0x7f3557908340)
Random.Xoshiro(s0=0xeb50203a54383b4d, s1=0x230b8f4e1fdfa4b0, s2=0x52d092b9f301e4c3, s3=0x0aacfda0920739dd, s4=0xe8f89f84afe83155)

which later get garbage-collected during the finally block (during some more inference), after the error, just before getting used in another dynamic call:

Base.copy!(Random.TaskLocalRNG(), <#0x7f3557908340>)

at

macro expansion at /home/vtjnash/julia1/usr/share/julia/stdlib/v1.12/Test/src/Test.jl:1777                     

@vtjnash
Copy link
Member

vtjnash commented Jan 8, 2025

smaller MWE: this always segfaults for me (unless I put it in a function)

let
   ()->() # trigger latestworld expr
   default_rng_orig = []
   try
       throw(ErrorException("This test is supposed to throw an error"))
   catch ex
       GC.gc()
       copy!([], default_rng_orig)
   end
   Base.Experimental.@force_compile
   nothing
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression Regression in behavior compared to a previous version
Projects
None yet
Development

No branches or pull requests

3 participants