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

Unreachable reached with NamedTuple of StaticVector #29718

Closed
tpapp opened this issue Oct 18, 2018 · 5 comments
Closed

Unreachable reached with NamedTuple of StaticVector #29718

tpapp opened this issue Oct 18, 2018 · 5 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior compiler:codegen Generation of LLVM IR and native code missing data Base.missing and related functionality

Comments

@tpapp
Copy link
Contributor

tpapp commented Oct 18, 2018

This is an MWE I isolated tracking down a bug, happens both on master and 1.0.1, and with the latest stable and master of StaticArrays.

using StaticArrays

const Foo{S} = SVector{S, UInt8}

nt = NamedTuple{(:penr,
                 :benr,
                 :jahr,
                 :bmg,
                 :sz,
                 :ef_bmg,
                 :_merge_wage,
                 :lmstat,
                 :fk_akgr,
                 :gebj,
                 :ampLevel,
                 ),
                Tuple{Union{Missing, Int32},
                      Int64,
                      Int16,
                      Union{Missing, Float64},
                      Union{Missing, Float64},
                      Foo{1},
                      Union{Missing, Int8},
                      Int8,
                      Foo{30},
                      Union{Missing, Int16},
                      Int8,
                      }
                }((1,
                   1,
                   2003,
                   missing,
                   missing,
                   zeros(Foo{1}),
                   1,
                   41,
                   zeros(Foo{30}),
                   1915,
                   21,
                   ))

produces the output

NamedTuple{(:penr, :benr, :jahr, :bmg, :sz, :ef_bmg, :_merge_wage, :lmstat, :fk_akgr, :gebj, :ampLevel),Tuple{Union{Missing, Int32},Int64,Int16,Union{Missing, Float64},Union{Missing, Float64},SArray{Tuple{1},UInt8,1,1},Union{Missing, Int8},Int8,SArray{Tuple{30},UInt8,1,30},Union{Missing, Int16},Int8}}(Unreachable reached at 0x7fda3cb1c146

signal (4): Illegal instruction
in expression starting at no file:0
macro expansion at ./namedtuple.jl:0 [inlined]
Type at ./namedtuple.jl:116 [inlined]
show at ./namedtuple.jl:132
show at ./sysimg.jl:194
unknown function (ip: 0x7fda3cb1b2f6)
jl_fptr_trampoline at /buildworker/worker/package_linux64/build/src/gf.c:1829
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2182
display at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:131
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2182
display at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:135
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2182
display at ./multimedia.jl:287
unknown function (ip: 0x7fda3cb1b102)
jl_fptr_trampoline at /buildworker/worker/package_linux64/build/src/gf.c:1829
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2182
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1536 [inlined]
jl_f__apply at /buildworker/worker/package_linux64/build/src/builtins.c:556
jl_f__apply_latest at /buildworker/worker/package_linux64/build/src/builtins.c:594
#invokelatest#1 at ./essentials.jl:686 [inlined]
invokelatest at ./essentials.jl:685 [inlined]
print_response at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:154
print_response at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:139
unknown function (ip: 0x7fda3cb130db)
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2182
do_respond at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:708
unknown function (ip: 0x7fda3cb06944)
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2182
#55 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:971
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2182
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1536 [inlined]
jl_f__apply at /buildworker/worker/package_linux64/build/src/builtins.c:556
jl_f__apply_latest at /buildworker/worker/package_linux64/build/src/builtins.c:594
#invokelatest#1 at ./essentials.jl:686 [inlined]
invokelatest at ./essentials.jl:685 [inlined]
#27 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/REPL/src/LineEdit.jl:1319
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2182
prompt! at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/REPL/src/LineEdit.jl:2353
run_interface at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/REPL/src/LineEdit.jl:2256
jl_fptr_trampoline at /buildworker/worker/package_linux64/build/src/gf.c:1829
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2182
run_frontend at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:1029
run_repl at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:191
jl_fptr_trampoline at /buildworker/worker/package_linux64/build/src/gf.c:1829
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2182
#720 at ./logging.jl:311
unknown function (ip: 0x7fda3cae5835)
jl_fptr_trampoline at /buildworker/worker/package_linux64/build/src/gf.c:1829
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2182
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1536 [inlined]
jl_f__apply at /buildworker/worker/package_linux64/build/src/builtins.c:556
jl_f__apply_latest at /buildworker/worker/package_linux64/build/src/builtins.c:594
#invokelatest#1 at ./essentials.jl:686 [inlined]
invokelatest at ./essentials.jl:685 [inlined]
macro expansion at ./logging.jl:308 [inlined]
run_main_repl at ./client.jl:330
exec_options at ./client.jl:242
_start at ./client.jl:421
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2182
unknown function (ip: 0x401ae8)
unknown function (ip: 0x401513)
__libc_start_main at /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
unknown function (ip: 0x4015b4)
Allocations: 12873016 (Pool: 12870598; Big: 2418); GC: 27

(cf: discourse)

@JeffBezanson JeffBezanson self-assigned this Oct 18, 2018
@JeffBezanson
Copy link
Member

Another even simpler case:

using StaticArrays

const Foo{S} = SVector{S, UInt8}

nt = NamedTuple{(:a, :b, :c, :d, :e, :f,),
                Tuple{Union{Missing, Float64},
                      Foo{1},
                      Union{Missing, Int8},
                      Int8,
                      Foo{2},
                      Union{Missing, Int16},
                      }
                }((missing,
                   zeros(Foo{1}),
                   1,
                   41,
                   zeros(Foo{2}),
                   1915,
                   ));
nt.f
signal (11): Segmentation fault
in expression starting at /home/jeff/src/julia/i29718.jl:72
jl_is_datatype_singleton at /home/jeff/src/julia/src/julia.h:1027
jl_get_nth_field at /home/jeff/src/julia/src/datatype.c:878
jl_f_getfield at /home/jeff/src/julia/src/builtins.c:663
getproperty at ./sysimg.jl:18

The union selector byte for the last field seems to be invalid.

@JeffBezanson
Copy link
Member

Something looks off here:

  %17 = getelementptr inbounds { i64, i8, { [1 x i8] }, i8, i8, i8, { [2 x i8] }, i8, i8, i8 }, { i64, i8, { [1 x i8] }, i8, i8, i8, { [2 x i8] }, i8, i8, i8 }* %4, i32 0, i32 8
  %18 = getelementptr inbounds { i64, i8, { [1 x i8] }, i8, i8, i8, { [2 x i8] }, i8, i8, i8 }, { i64, i8, { [1 x i8] }, i8, i8, i8, { [2 x i8] }, i8, i8, i8 }* %4, i32 0, i32 9
  store i8 1, i8* %18
  %19 = bitcast i8* %17 to i16*
  store i16 1915, i16* %19

The data for the Union{Missing, Int16} field is 3 i8s, but the data store seems to start at the second byte instead of the first if I'm reading this right.

JeffBezanson added a commit that referenced this issue Oct 19, 2018
@JeffBezanson JeffBezanson added bug Indicates an unexpected problem or unintended behavior compiler:codegen Generation of LLVM IR and native code missing data Base.missing and related functionality labels Oct 19, 2018
JeffBezanson added a commit that referenced this issue Oct 19, 2018
@tpapp
Copy link
Contributor Author

tpapp commented Oct 19, 2018

That could be. For some other named tuples I don't trigger the segfault, but get different values for

nt.somefield
map(identity, nt).somefield

I can make an MWE of that too if that helps.

@JeffBezanson
Copy link
Member

See if #29722 fixes the other cases as well.

@tpapp
Copy link
Contributor Author

tpapp commented Oct 19, 2018

@JeffBezanson: I can confirm that #29722 fixes the other cases. Thanks for the quick solution!

JeffBezanson added a commit that referenced this issue Oct 19, 2018
JeffBezanson added a commit that referenced this issue Oct 19, 2018
KristofferC pushed a commit that referenced this issue Oct 29, 2018
KristofferC pushed a commit that referenced this issue Feb 11, 2019
KristofferC pushed a commit that referenced this issue Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior compiler:codegen Generation of LLVM IR and native code missing data Base.missing and related functionality
Projects
None yet
Development

No branches or pull requests

2 participants