JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.73k stars 5.49k forks source link

RetentionParameterEstimator hits incorrect assert in emit_masked_bits_compare #55513

Open vtjnash opened 2 months ago

vtjnash commented 2 months ago

testiing RetentionParameterEstimator (using Mocking pinned to an older version without ScopedValue) fails with

julia: /home/vtjnash/julia/src/codegen.cpp:3386: size_t emit_masked_bits_compare(callback&, jl_datatype_t*, egal_desc&) [with callback = emit_bits_compare(jl_cod
ectx_t&, jl_cgval_t, jl_cgval_t)::<lambda(egal_desc)>; size_t = long unsigned int; jl_datatype_t = _jl_datatype_t]: Assertion `fty->layout->flags.isbitsegal' fai
led.                                                                            

[1595716] signal 6 (-6): Aborted                                                
in expression starting at /home/vtjnash/.julia/packages/RetentionParameterEstimator/vLG9K/test/runtests.jl:20                                                    
pthread_kill at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)                  
raise at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)                                                                                                          
abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)                                                                                                          
unknown function (ip: 0x7fdcb9b1071a)                                                                                                                            
__assert_fail at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)                                                                                                  
emit_masked_bits_compare<emit_bits_compare(jl_codectx_t&, jl_cgval_t, jl_cgval_t)::<lambda(egal_desc)> > at /home/vtjnash/julia/src/codegen.cpp:3386             
emit_masked_bits_compare<emit_bits_compare(jl_codectx_t&, jl_cgval_t, jl_cgval_t)::<lambda(egal_desc)> > at /home/vtjnash/julia/src/codegen.cpp:3413             
emit_masked_bits_compare<emit_bits_compare(jl_codectx_t&, jl_cgval_t, jl_cgval_t)::<lambda(egal_desc)> > at /home/vtjnash/julia/src/codegen.cpp:3413             
emit_masked_bits_compare<emit_bits_compare(jl_codectx_t&, jl_cgval_t, jl_cgval_t)::<lambda(egal_desc)> > at /home/vtjnash/julia/src/codegen.cpp:3413             
emit_bits_compare at /home/vtjnash/julia/src/codegen.cpp:3570                                                                                                    
operator() at /home/vtjnash/julia/src/codegen.cpp:3674 [inlined]                                                                                                 
operator() at /home/vtjnash/julia/src/codegen.cpp:3663                                                                                                           
emit_nullcheck_guard<emit_f_is(jl_codectx_t&, const jl_cgval_t&, const jl_cgval_t&, llvm::Value*, llvm::Value*)::<lambda()>&> at /home/vtjnash/julia/src/cgutils.
cpp:1498 [inlined]                                                                                                                                               
emit_nullcheck_guard2<emit_f_is(jl_codectx_t&, const jl_cgval_t&, const jl_cgval_t&, llvm::Value*, llvm::Value*)::<lambda()> > at /home/vtjnash/julia/src/cgutils
.cpp:1507 [inlined]                                                                                                                                              
emit_f_is at /home/vtjnash/julia/src/codegen.cpp:3663                                                                                                            

The compared type is

SciMLBase.ODEFunction{false, SciMLBase.AutoSpecialize, GasChromatographySimulator.var"#f_τ²z#100"{GasChromatographySimulator.var"#t#99"{SciMLBase.ODESolution{Float64, 1, Array{Float64, 1}, Nothing, Nothing, Array{Float64, 1}, Array{Array{Float64, 1}, 1}, Nothing, SciMLBase.ODEProblem{Float64, Tuple{Float64, Float64}, false, Tuple{Interpolations.Extrapolation{Float64, 2, Interpolations.GriddedInterpolation{Float64, 2, Array{Real, 2}, Interpolations.Gridded{Interpolations.Linear{Interpolations.Throw{Interpolations.OnGrid}}}, Tuple{Base.StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, Array{Float64, 1}}}, Interpolations.Gridded{Interpolations.Linear{Interpolations.Throw{Interpolations.OnGrid}}}, Interpolations.Flat{Nothing}}, Interpolations.Extrapolation{Float64, 1, Interpolations.GriddedInterpolation{Float64, 1, Array{Real, 1}, Interpolations.Gridded{Interpolations.Linear{Interpolations.Throw{Interpolations.OnGrid}}}, Tuple{Array{Float64, 1}}}, Interpolations.Gridded{Interpolations.Linear{Interpolations.Throw{Interpolations.OnGrid}}}, Interpolations.Flat{Nothing}}, Interpolations.Extrapolation{Float64, 1, Interpolations.GriddedInterpolation{Float64, 1, Array{Float64, 1}, Interpolations.Gridded{Interpolations.Linear{Interpolations.Throw{Interpolations.OnGrid}}}, Tuple{Array{Float64, 1}}}, Interpolations.Gridded{Interpolations.Linear{Interpolations.Throw{Interpolations.OnGrid}}}, Interpolations.Flat{Nothing}}, Float64, Float64, Float64, Float64, Float64, Float64, Float64, String, GasChromatographySimulator.Options}, SciMLBase.ODEFunction{false, SciMLBase.AutoSpecialize, GasChromatographySimulator.var"#f_tz#96", LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing, Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, OrdinaryDiffEq.OwrenZen5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, OrdinaryDiffEq.InterpolationData{SciMLBase.ODEFunction{false, SciMLBase.AutoSpecialize, GasChromatographySimulator.var"#f_tz#96", LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing, Nothing, Nothing}, Array{Float64, 1}, Array{Float64, 1}, Array{Array{Float64, 1}, 1}, Nothing, OrdinaryDiffEq.OwrenZen5ConstantCache{Float64, Float64}, Nothing}, SciMLBase.DEStats, Nothing, Nothing, Nothing}}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing, Nothing, Nothing}

The specific inlined value is of type

(rr) p jl_(aty)
SciMLBase.ODESolution{Float64, 1, Array{Float64, 1}, Nothing, Nothing, Array{Float64, 1}, Array{Array{Float64, 1}, 1}, Nothing, SciMLBase.ODEProblem{Float64, Tuple{Float64, Float64}, false, Tuple{Interpolations.Extrapolation{Float64, 2, Interpolations.GriddedInterpolation{Float64, 2, Array{Real, 2}, Interpolations.Gridded{Interpolations.Linear{Interpolations.Throw{Interpolations.OnGrid}}}, Tuple{Base.StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, Array{Float64, 1}}}, Interpolations.Gridded{Interpolations.Linear{Interpolations.Throw{Interpolations.OnGrid}}}, Interpolations.Flat{Nothing}}, Interpolations.Extrapolation{Float64, 1, Interpolations.GriddedInterpolation{Float64, 1, Array{Real, 1}, Interpolations.Gridded{Interpolations.Linear{Interpolations.Throw{Interpolations.OnGrid}}}, Tuple{Array{Float64, 1}}}, Interpolations.Gridded{Interpolations.Linear{Interpolations.Throw{Interpolations.OnGrid}}}, Interpolations.Flat{Nothing}}, Interpolations.Extrapolation{Float64, 1, Interpolations.GriddedInterpolation{Float64, 1, Array{Float64, 1}, Interpolations.Gridded{Interpolations.Linear{Interpolations.Throw{Interpolations.OnGrid}}}, Tuple{Array{Float64, 1}}}, Interpolations.Gridded{Interpolations.Linear{Interpolations.Throw{Interpolations.OnGrid}}}, Interpolations.Flat{Nothing}}, Float64, Float64, Float64, Float64, Float64, Float64, Float64, String, GasChromatographySimulator.Options}, SciMLBase.ODEFunction{false, SciMLBase.AutoSpecialize, GasChromatographySimulator.var"#f_tz#96", LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing, Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, OrdinaryDiffEq.OwrenZen5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, OrdinaryDiffEq.InterpolationData{SciMLBase.ODEFunction{false, SciMLBase.AutoSpecialize, GasChromatographySimulator.var"#f_tz#96", LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing, Nothing, Nothing}, Array{Float64, 1}, Array{Float64, 1}, Array{Array{Float64, 1}, 1}, Nothing, OrdinaryDiffEq.OwrenZen5ConstantCache{Float64, Float64}, Nothing}, SciMLBase.DEStats, Nothing, Nothing, Nothing}
(rr) p *aty->layout
$71 = {size = 640, nfields = 16, npointers = 8, first_ptr = 0, alignment = 8, flags = {haspadding = 1, fielddesc_type = 1, arrayelem_isboxed = 0, arrayelem_isunion = 0, isbitsegal = 1, padding = 0}}

The layout of this type is

(rr) p *((jl_datatype_t*)aty)->layout
$46 = {size = 640, nfields = 16, npointers = 8, first_ptr = 0, alignment = 8, flags = {haspadding = 1, fielddesc_type = 1, arrayelem_isboxed = 0, arrayelem_isunion = 0, isbitsegal = 1, padding = 0}}
(rr) p *((const jl_fielddesc16_t*)(aty->layout + 1) + 0)
$116 = {isptr = 1, size = 8, offset = 0}
(rr) p *((const jl_fielddesc16_t*)(aty->layout + 1) + 1)
$117 = {isptr = 0, size = 0, offset = 8}
(rr) p *((const jl_fielddesc16_t*)(aty->layout + 1) + 2)
$118 = {isptr = 0, size = 0, offset = 8}
(rr) p *((const jl_fielddesc16_t*)(aty->layout + 1) + 3)
$119 = {isptr = 1, size = 8, offset = 8}
(rr) p *((const jl_fielddesc16_t*)(aty->layout + 1) + 4)
$120 = {isptr = 1, size = 8, offset = 16}
(rr) p *((const jl_fielddesc16_t*)(aty->layout + 1) + 5)
$121 = {isptr = 0, size = 0, offset = 24}
(rr) p *((const jl_fielddesc16_t*)(aty->layout + 1) + 6)
$122 = {isptr = 1, size = 8, offset = 24}
(rr) p *((const jl_fielddesc16_t*)(aty->layout + 1) + 7)
$123 = {isptr = 0, size = 0, offset = 32}
(rr) p *((const jl_fielddesc16_t*)(aty->layout + 1) + 8)
$124 = {isptr = 0, size = 576, offset = 32}
(rr) p *((const jl_fielddesc16_t*)(aty->layout + 1) + 9)
$125 = {isptr = 0, size = 1, offset = 608}
(rr) p *((const jl_fielddesc16_t*)(aty->layout + 1) + 10)
$126 = {isptr = 0, size = 8, offset = 616}
(rr) p *((const jl_fielddesc16_t*)(aty->layout + 1) + 11)
$127 = {isptr = 1, size = 8, offset = 624}
(rr) p *((const jl_fielddesc16_t*)(aty->layout + 1) + 12)
$128 = {isptr = 0, size = 0, offset = 632}
(rr) p *((const jl_fielddesc16_t*)(aty->layout + 1) + 13)
$129 = {isptr = 0, size = 4, offset = 632}
(rr) p *((const jl_fielddesc16_t*)(aty->layout + 1) + 1)
$130 = {isptr = 0, size = 0, offset = 8}
(rr) p *((const jl_fielddesc16_t*)(aty->layout + 1) + 14)
$131 = {isptr = 0, size = 0, offset = 636}
(rr) p *((const jl_fielddesc16_t*)(aty->layout + 1) + 15)
$132 = {isptr = 0, size = 0, offset = 636}

While field 6 is the one that fails this check:

(rr) p *((jl_datatype_t*)jl_field_type(aty, 6))->layout
$141 = {size = 256, nfields = 6, npointers = 14, first_ptr = 10, alignment = 8, flags = {haspadding = 1, fielddesc_type = 1, arrayelem_isboxed = 0, arrayelem_isunion = 0, isbitsegal = 0, 
    padding = 0}}

Originally posted by @nsajko in https://github.com/JuliaLang/julia/issues/55466#issuecomment-2292210490

JeffBezanson commented 2 months ago

It looks like this code is not in 1.11 so removing milestone. Let's watch carefully for this code getting backported :joy: