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

Error: unsigned int convert_struct_offset(llvm::Type*, unsigned int): Assertion `SL->getElementOffset(idx) == byte_offset' failed #45460

Closed
atbug opened this issue May 26, 2022 · 6 comments

Comments

@atbug
Copy link

atbug commented May 26, 2022

I don't have a MWE yet but here it is in my package CI for Julia 1.7:

https://github.com/Hop-developers/Hop.jl/runs/6604926044

This issue doesn't happen on Julia 1.6.

If anyone tries to look into this, to test Hop.jl (not registered yet), one needs to put all the data in https://github.com/Hop-developers/HopTestData into the test/data folder in Hop.jl and then run runtests.jl.

@atbug
Copy link
Author

atbug commented May 26, 2022

A similar issue (fixed) here: #34288

@vtjnash
Copy link
Member

vtjnash commented May 26, 2022

Are you familiar enough with GDB that you could print out the value of the type that is failing there (e.g. print jl_dump_llvm_type(lty))

@atbug
Copy link
Author

atbug commented May 26, 2022

Are you familiar enough with GDB that you could print out the value of the type that is failing there (e.g. print jl_dump_llvm_type(lty))

Unfortunately, no. But I have reduced the example to something that does not need HopTestData:

using Hop
tm = Hop.SharedTBModel(Hop.Zoo.getBN())
Hop.Optics.get_shift_cond(tm, 2, 2, [3.2], -6.0, [5, 5, 1], ϵ=0.1)

It seems the problem comes from SharedArrays.

I also tried to obtain an rr trace here:
https://s3.amazonaws.com/julialang-dumps/reports/2022-05-26T19-31-02-atbug.tar.zst

But I am not sure I ran rr correctly since it complained: "[FATAL src/PerfCounters.cc:219:start_counter()] Unable to open performance counter with 'perf_event_open'; are hardware perf events available? See https://github.com/rr-debugger/rr/wiki/Will-rr-work-on-my-system". I was running rr on a vultr instance since I don't have sudo access on my cluster.

@vtjnash
Copy link
Member

vtjnash commented May 26, 2022

Looks like the rr file is empty.

Thread 1 "julia" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) up
#1  0x00007ffff7da9859 in __GI_abort () at abort.c:79
79      abort.c: No such file or directory.
(gdb) 
#2  0x00007ffff7da9729 in __assert_fail_base (fmt=0x7ffff7f3f588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x7ffff77498a0 "SL->getElementOffset(idx) == byte_offset", 
    file=0x7ffff7748930 "/data/vtjnash/julia17/src/cgutils.cpp", line=480, function=<optimized out>) at assert.c:92
92      assert.c: No such file or directory.
(gdb) 
#3  0x00007ffff7dbb006 in __GI___assert_fail (assertion=assertion@entry=0x7ffff77498a0 "SL->getElementOffset(idx) == byte_offset", 
    file=file@entry=0x7ffff7748930 "/data/vtjnash/julia17/src/cgutils.cpp", line=line@entry=480, 
    function=function@entry=0x7ffff7749860 "unsigned int convert_struct_offset(llvm::Type*, unsigned int)") at assert.c:101
101     in assert.c
(gdb) 
#4  0x00007ffff756bc46 in convert_struct_offset (lty=<optimized out>, byte_offset=<optimized out>) at /data/vtjnash/julia17/src/cgutils.cpp:475
475     static unsigned convert_struct_offset(Type *lty, unsigned byte_offset)
(gdb) 
#5  convert_struct_offset (lty=<optimized out>, byte_offset=<optimized out>) at /data/vtjnash/julia17/src/cgutils.cpp:475
475     static unsigned convert_struct_offset(Type *lty, unsigned byte_offset)
(gdb) 
#6  0x00007ffff759aae8 in convert_struct_offset (ctx=..., byte_offset=208, lty=0x55555767e8e0) at /data/vtjnash/julia17/src/cgutils.cpp:486
486         return convert_struct_offset(lty, byte_offset);
(gdb) p lty
$1 = (llvm::Type *) 0x55555767e8e0
(gdb) p jl_dump_llvm_type(lty)
{ double, { i64, i8, [1 x [9 x double]], [1 x [9 x double]], {} addrspace(10)*, {} addrspace(10)*, {} addrspace(10)*, {} addrspace(10)*, [1 x [3 x {} addrspace(10)*]] }, i64, i64, i64, {} addrspace(10)*, double, {} addrspace(10)* }
$2 = void
(gdb) up
#7  emit_new_struct (ctx=..., ty=0x7fff8e55e720, nargs=8, argv=<optimized out>) at /data/vtjnash/julia17/src/cgutils.cpp:3439
3439                    unsigned llvm_idx = (i > 0 && isa<StructType>(lt)) ? convert_struct_offset(ctx, lt, offs) : i;
(gdb) list -
3434                    Type *fty = julia_type_to_llvm(ctx, jtype);
3435                    if (type_is_ghost(fty))
3436                        continue;
3437                    Value *dest = NULL;
3438                    unsigned offs = jl_field_offset(sty, i);
3439                    unsigned llvm_idx = (i > 0 && isa<StructType>(lt)) ? convert_struct_offset(ctx, lt, offs) : i;
3440                    if (!init_as_value) {
3441                        // avoid unboxing the argument explicitly
3442                        // and use memcpy instead
3443                        dest = ctx.builder.CreateConstInBoundsGEP2_32(lt, strct, 0, llvm_idx);
(gdb) p jl_(sty)
Hop.Optics.var"#11#13"{Float64, Hop.SharedTBModel{Base.Complex{Float64}}, Int64, Int64, Int64, Array{Float64, 1}, Float64, Array{SharedArrays.SharedArray{Float64, 1}, 1}}
$3 = void
(gdb) p jl_(sty->types)
svec(Float64, Hop.SharedTBModel{Base.Complex{Float64}}, Int64, Int64, Int64, Array{Float64, 1}, Float64, Array{SharedArrays.SharedArray{Float64, 1}, 1})
$4 = void
(gdb) p offs
$5 = 208
(gdb) p i
$6 = 2

This appears to be fixed on master.

julia> fieldtypes(Hop.SharedTBModel{Base.Complex{Float64}})
(Int64, Bool, StaticArrays.SMatrix{3, 3, Float64, 9}, StaticArrays.SMatrix{3, 3, Float64, 9}, Matrix{Int16}, Matrix{Float64}, SharedArrays.SharedMatrix{ComplexF64}, Union{Nothing, SharedArrays.SharedMatrix{ComplexF64}}, StaticArrays.SVector{3, SharedArrays.SharedMatrix{ComplexF64}})

julia> map(i -> fieldoffset(Hop.SharedTBModel{Base.Complex{Float64}}, i), 1:9)
9-element Vector{UInt64}:
 0x0000000000000000
 0x0000000000000008
 0x0000000000000010
 0x0000000000000058
 0x00000000000000a0
 0x00000000000000a8
 0x00000000000000b0
 0x00000000000000b8
 0x00000000000000c0

julia> sizeof(Hop.SharedTBModel{Base.Complex{Float64}}) |> UInt
0x00000000000000c8 # v1.7.3
julia> sizeof(Hop.SharedTBModel{Base.Complex{Float64}}) |> UInt
0x00000000000000d8 # master

@vtjnash
Copy link
Member

vtjnash commented May 26, 2022

I believe this will not be fixed as there is not a plan for another v1.7 release, given that v1.8.0 is about to be available.

@atbug
Copy link
Author

atbug commented May 26, 2022

Fair enough. Thank you.

@atbug atbug closed this as completed May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants