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

Inference error with Array{Union{Int,Missing}} after resize #27767

Closed
shashi opened this issue Jun 25, 2018 · 2 comments
Closed

Inference error with Array{Union{Int,Missing}} after resize #27767

shashi opened this issue Jun 25, 2018 · 2 comments
Labels
bug Indicates an unexpected problem or unintended behavior missing data Base.missing and related functionality

Comments

@shashi
Copy link
Contributor

shashi commented Jun 25, 2018

When I resize the array, julia errors trying to print it.

julia> x=Array{Union{Int, Missing}}(undef, 1)
1-element Array{Union{Missing, Int64},1}:
 missing

julia> resize!(x, 100)
100-element Array{Union{Missing, Int64},1}:
Error showing value of type Array{Union{Missing, Int64},1}:
ERROR: fatal error in type inference (type bound)
Stacktrace:
 [1] alignment(::IOContext{REPL.Terminals.TTYTerminal}, ::Array{Union{Missing, Int64},1}, ::Array{Int64,1}, ::Base.OneTo{Int64}, ::Int64, ::Int64, ::Int64) at ./arrayshow.jl:68
 [2] print_matrix(::IOContext{REPL.Terminals.TTYTerminal}, ::Array{Union{Missing, Int64},1}, ::String, ::String, ::String, ::String, ::String, ::String, ::Int64, ::Int64) at ./arrayshow.jl:186
 [3] print_matrix at ./arrayshow.jl:159 [inlined]
 [4] print_array at ./arrayshow.jl:308 [inlined]
 [5] show(::IOContext{REPL.Terminals.TTYTerminal}, ::MIME{Symbol("text/plain")}, ::Array{Union{Missing, Int64},1}) at ./arrayshow.jl:344
 [6] display(::REPL.REPLDisplay{REPL.LineEditREPL}, ::MIME{Symbol("text/plain")}, ::Array{Union{Missing, Int64},1}) at /home/shashi/code/julia/stdlib/REPL/src/REPL.jl:130
 [7] display(::REPL.REPLDisplay{REPL.LineEditREPL}, ::Array{Union{Missing, Int64},1}) at /home/shashi/code/julia/stdlib/REPL/src/REPL.jl:133
 [8] display(::Array{Union{Missing, Int64},1}) at ./multimedia.jl:287
 [9] #invokelatest#1 at ./essentials.jl:670 [inlined]
 [10] invokelatest at ./essentials.jl:669 [inlined]
 [11] print_response(::REPL.Terminals.TTYTerminal, ::Any, ::Nothing, ::Bool, ::Bool, ::Nothing) at /home/shashi/code/julia/stdlib/REPL/src/REPL.jl:151
 [12] print_response(::REPL.LineEditREPL, ::Any, ::Nothing, ::Bool, ::Bool) at /home/shashi/code/julia/stdlib/REPL/src/REPL.jl:137
 [13] (::getfield(REPL, Symbol("#do_respond#42")){Bool,getfield(REPL, Symbol("##52#61")){REPL.LineEditREPL,REPL.REPLHistoryProvider},REPL.LineEditREPL,REPL.LineEdit.Prompt})(::REPL.LineEdit.MIState, ::Base.GenericIOBuffer{Array{UInt8,1}}, ::Bool) at /home/shashi/code/julia/stdlib/REPL/src/REPL.jl:706
 [14] top-level scope at none:0

Now if I try to do typeof on each element:

julia> map(typeof, x)
Unreachable reached at 0x7f943056711b

signal (4): Illegal instruction
in expression starting at no file:0
getindex at ./array.jl:707 [inlined]
iterate at ./array.jl:682 [inlined]
iterate at ./generator.jl:44 [inlined]
collect_to! at ./array.jl:630 [inlined]
collect_to_with_first! at ./array.jl:617
unknown function (ip: 0x7f9430567163)
jl_fptr_trampoline at /home/shashi/code/julia/src/gf.c:1813
jl_apply_generic at /home/shashi/code/julia/src/gf.c:2151
_collect at ./array.jl:611
collect_similar at ./array.jl:535
jl_fptr_trampoline at /home/shashi/code/julia/src/gf.c:1813
jl_apply_generic at /home/shashi/code/julia/src/gf.c:2151
map at ./abstractarray.jl:1964
jl_fptr_trampoline at /home/shashi/code/julia/src/gf.c:1813
jl_apply_generic at /home/shashi/code/julia/src/gf.c:2151
do_call at /home/shashi/code/julia/src/interpreter.c:324
eval_value at /home/shashi/code/julia/src/interpreter.c:428
eval_stmt_value at /home/shashi/code/julia/src/interpreter.c:363 [inlined]
eval_body at /home/shashi/code/julia/src/interpreter.c:671
jl_interpret_toplevel_thunk_callback at /home/shashi/code/julia/src/interpreter.c:788
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x7f943341d20f)
unknown function (ip: 0xffffffffffffffff)
jl_interpret_toplevel_thunk at /home/shashi/code/julia/src/interpreter.c:797
jl_toplevel_eval_flex at /home/shashi/code/julia/src/toplevel.c:814
jl_toplevel_eval_in at /home/shashi/code/julia/src/builtins.c:631
eval at ./boot.jl:319
jl_apply_generic at /home/shashi/code/julia/src/gf.c:2151
eval_user_input at /home/shashi/code/julia/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:85
macro expansion at /home/shashi/code/julia/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:116 [inlined]
#28 at ./task.jl:257
jl_fptr_trampoline at /home/shashi/code/julia/src/gf.c:1813
jl_apply_generic at /home/shashi/code/julia/src/gf.c:2151
jl_apply at /home/shashi/code/julia/src/julia.h:1533 [inlined]
start_task at /home/shashi/code/julia/src/task.c:268
unknown function (ip: 0xffffffffffffffff)
Allocations: 4864217 (Pool: 4863286; Big: 931); GC: 9
Illegal instruction (core dumped)

Could be another issue or a clue to the first one.

@martinholters
Copy link
Member

Seems to be a problem with the new values being uninitialized. Doing e.g. fill!(resize!(x, 100), missing), everything seems to work smoothly. I guess we should not leave the values that uninitialized.

@quinnj
Copy link
Member

quinnj commented Jun 25, 2018

Yeah, any resizing of isbitsunion Arrays should do a memset on the new type tag bytes to 0.

@nalimilan nalimilan added bug Indicates an unexpected problem or unintended behavior missing data Base.missing and related functionality labels Jun 25, 2018
@quinnj quinnj closed this as completed in f1cc425 Jun 26, 2018
quinnj added a commit that referenced this issue Jun 26, 2018
Fix #27767. Fix a missing memset when resizing isbitsunion arrays
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 missing data Base.missing and related functionality
Projects
None yet
Development

No branches or pull requests

4 participants