A private code uses the following type:
struct TransportSolution{N,T,S,P<:AbstractTransportProblem{N,T}}
tp::P
dom::Vector{S}
bnd::SparseVector{Array{S,1},Int64}
end
H
is an instance of this type, for which there is no reshape method, so:
julia> @which reshape(H, 1, 2, 3)
ERROR: no method found for the specified argument types
Stacktrace:
[1] which(::Any, ::Any) at ./reflection.jl:823
However if one attempts to reshape:
julia> reshape(H, 1, 2, 3)
ERROR:
signal (11): Segmentation fault
while loading no file, in expression starting on line 0
show_datatype at ./show.jl:215
show at ./show.jl:211
unknown function (ip: 0x7fbb086a008f)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
print at ./strings/io.jl:29
unknown function (ip: 0x7fbad8676be6)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
#print_to_string#229 at ./strings/io.jl:102
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
string at ./strings/io.jl:120
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
show_method_candidates at ./replutil.jl:511
unknown function (ip: 0x7fbad86758ed)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
showerror at ./replutil.jl:415
#473 at ./replutil.jl:213
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
#with_output_color#509 at ./util.jl:400
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
with_output_color at ./util.jl:397
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
#showerror#472 at ./replutil.jl:212
unknown function (ip: 0x7fbad866e079)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
jl_apply at /home/spowell/julia/src/julia.h:1424 [inlined]
jl_invoke at /home/spowell/julia/src/gf.c:51
showerror at ./replutil.jl:211
unknown function (ip: 0x7fbad866dded)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
display_error at ./client.jl:137
unknown function (ip: 0x7fbad866dd1d)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
do_call at /home/spowell/julia/src/interpreter.c:75
eval at /home/spowell/julia/src/interpreter.c:242
eval_body at /home/spowell/julia/src/interpreter.c:539
jl_toplevel_eval_body at /home/spowell/julia/src/interpreter.c:511
jl_toplevel_eval_flex at /home/spowell/julia/src/toplevel.c:571
jl_toplevel_eval_in at /home/spowell/julia/src/builtins.c:496
eval at ./boot.jl:235
unknown function (ip: 0x7fbb086f385f)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
print_response at ./REPL.jl:137
unknown function (ip: 0x7fbad865ae8d)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
print_response at ./REPL.jl:129
unknown function (ip: 0x7fbad865ab8d)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
do_respond at ./REPL.jl:646
unknown function (ip: 0x7fbad8633c51)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
do_call at /home/spowell/julia/src/interpreter.c:75
eval at /home/spowell/julia/src/interpreter.c:242
eval_body at /home/spowell/julia/src/interpreter.c:539
jl_toplevel_eval_body at /home/spowell/julia/src/interpreter.c:511
jl_toplevel_eval_flex at /home/spowell/julia/src/toplevel.c:571
jl_toplevel_eval_in at /home/spowell/julia/src/builtins.c:496
eval at ./boot.jl:235
unknown function (ip: 0x7fbb086f385f)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
run_interface at ./LineEdit.jl:1583
unknown function (ip: 0x7fbb08757e1f)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
run_frontend at ./REPL.jl:945
run_repl at ./REPL.jl:180
unknown function (ip: 0x7fbad85f73f2)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
_start at ./client.jl:413
unknown function (ip: 0x7fbb08735b88)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
unknown function (ip: 0x401df0)
unknown function (ip: 0x4015b2)
__libc_start_main at /build/glibc-bfm8X4/glibc-2.23/csu/../csu/libc-start.c:291
unknown function (ip: 0x401668)
Allocations: 13856908 (Pool: 13854700; Big: 2208); GC: 29
Segmentation fault (core dumped)
Happy to do some proxy-debugging or could provide access to established members.
It crashes while trying to show some error, and it also involves show_method_candidates
, so presumably the expected MethodError
is thrown, but then when the REPL tries to display it, something goes wrong. Do you have any reshape
methods defined in your project? Does try reshape(H, 1, 2, 3) catch end
prevent the crash?
try reshape(H, 1, 2, 3) catch end
indeed prevents the crash.
There are no reshape
methods defined in my project. H
used to be of a type which was a subtype of AbstractArray
, hence why this old code fragment got called during a partial refactor.
To be sure we're on the same page: This is with Julia 0.6? Or master?
Can you verify you get something like
julia> try
reshape(H, 1, 2, 3)
catch e
e
end
MethodError(reshape, (TransportSolution{2,Float64,Float32,AbstractTransportProblem{2,Float64}}, 1, 2, 3), 0x00000000000056ee)
(The inner types obviously depend on your actual H
and the hex value may be different, but at least it shouldn't crash.)
OTOH, this presumably crashes?
julia> try
reshape(H, 1, 2, 3)
catch e
Base.show_method_candidates(STDOUT, e, Any[])
end
Does methods(reshape)
still work?
Thanks Martin. This is 0.6.0
on macOS and Linux.
This works:
julia> try
H = reshape(H, 1,2,3,4)
catch e
e
end
MethodError(reshape, (Transport.TransportSolution{3,Float32,Float32,Transport.RTE{3,Float32}}...
As you assumed this indeed fails:
julia> try
reshape(H, 1, 2, 3)
catch e
Base.show_method_candidates(STDOUT, e, Any[])
end
signal (11): Segmentation fault: 11
while loading no file, in expression starting on line 4
show_datatype at ./show.jl:215
show at ./show.jl:211
jlcall_show_15665 at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
print at ./strings/io.jl:29
unknown function (ip: 0x119a54306)
#print_to_string#229 at ./strings/io.jl:102
string at ./strings/io.jl:120
show_method_candidates at ./replutil.jl:511
unknown function (ip: 0x119a5251d)
do_call at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/interpreter.c:75
eval at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/interpreter.c:242
eval_body at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/interpreter.c:543
jl_interpret_toplevel_thunk at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/interpreter.c:692
jl_toplevel_eval_flex at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/toplevel.c:592
jl_toplevel_eval_in at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/builtins.c:496
eval at ./boot.jl:235
jlcall_eval_17976 at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
eval_user_input at ./REPL.jl:66
jlcall_eval_user_input_20272 at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
macro expansion at ./REPL.jl:97 [inlined]
#1 at ./event.jl:73
unknown function (ip: 0x11999a9df)
jl_apply at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/./julia.h:1424 [inlined]
start_task at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/task.c:267
Allocations: 16357949 (Pool: 16355638; Big: 2311); GC: 39
And methods(reshape)
fails after I bring my module into scope:
```
julia> methods(reshape)
reshape(a::Array{T,N}, dims::Tuple{Vararg{Int64,N}}) where {N, T} in Base at array.jl:170
reshape(a::Array{T,N} where N, dims::Tuple{Vararg{Int64,N}}) where {N, T} in Base at array.jl:181
reshape(parent::AbstractArray, dims::Int64...) in Base at reshapedarray.jl:95
reshape(parent::AbstractArray, dims::Union{AbstractUnitRange, Int64}...) in Base at reshapedarray.jl:90
reshape(B::BitArray{N}, dims::Tuple{Vararg{Int64,N}}) where N in Base at bitarray.jl:477
reshape(B::BitArray, dims::Tuple{Vararg{Int64,N} where N}) in Base at bitarray.jl:479
reshape(a::SharedArray{T,N} where N, dims::Tuple{Vararg{Int64,N}}) where {T, N} in Base at sharedarray.jl:273
reshape(parent::AbstractArray, dims::Tuple{Vararg{Int64,N}} where N) in Base at reshapedarray.jl:92
reshape(parent::AbstractArray, dims::Tuple{Vararg{Union{Colon, Int64},N} where N}) in Base at reshapedarray.jl:97
reshape(parent::AbstractArray, shp::Union{Tuple{Base.OneTo,Vararg{Base.OneTo,N} where N}, Tuple{Integer,Vararg{Integer,N} where N}}) in Base at reshapedarray.jl:91
reshape(parent::AbstractArray, dims::Union{Colon, Int64}...) in Base at reshapedarray.jl:96
reshape(parent::AbstractArray{T,N}, ndims::Type{Val{N}}) where {T, N} in Base at reshapedarray.jl:112
reshape(parent::AbstractArray, ndims::Type{Val{N}}) where N in Base at reshapedarray.jl:114
julia> using Transport
julia> methods(reshape)
reshape(a::Array{T,N}, dims::Tuple{Vararg{Int64,N}}) where {N, T} in Base at array.jl:170
reshape(a::Array{T,N} where N, dims::Tuple{Vararg{Int64,N}}) where {N, T} in Base at array.jl:181
reshape(parent::AbstractArray, dims::Int64...) in Base at reshapedarray.jl:95
reshape(parent::AbstractArray, dims::Union{AbstractUnitRange, Int64}...) in Base at reshapedarray.jl:90
reshape(B::BitArray{N}, dims::Tuple{Vararg{Int64,N}}) where N in Base at bitarray.jl:477
reshape(B::BitArray, dims::Tuple{Vararg{Int64,N} where N}) in Base at bitarray.jl:479
reshape(a::SharedArray{T,N} where N, dims::Tuple{Vararg{Int64,N}}) where {T, N} in Base at sharedarray.jl:273
signal (11): Segmentation fault: 11
while loading no file, in expression starting on line 0
show_datatype at ./show.jl:215
show at ./show.jl:211
unknown function (ip: 0x11d020846)
print at ./strings/io.jl:29
unknown function (ip: 0x11d0207b6)
jl_apply at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/./julia.h:1424 [inlined]
jl_f__apply at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/builtins.c:426
argtype_decl at ./methodshow.jl:42
unknown function (ip: 0x11d01ff53)
arg_decl_parts at ./methodshow.jl:61
unknown function (ip: 0x11d04ed52)
show_method_table at ./methodshow.jl:156
unknown function (ip: 0x11d04d7e8)
display at /Users/samuelpowell/.julia/v0.6/OhMyREPL/src/output_prompt_overwrite.jl:8
unknown function (ip: 0x11d04cbf6)
display at ./REPL.jl:125
unknown function (ip: 0x11d04c846)
display at ./multimedia.jl:194
unknown function (ip: 0x11d04c632)
do_call at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/interpreter.c:75
eval at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/interpreter.c:242
eval_body at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/interpreter.c:539
jl_toplevel_eval_body at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/interpreter.c:511
jl_toplevel_eval_flex at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/toplevel.c:571
jl_toplevel_eval_in at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/builtins.c:496
eval at ./boot.jl:235
jlcall_eval_17976 at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
print_response at ./REPL.jl:144
unknown function (ip: 0x11d04bbe8)
print_response at ./REPL.jl:129
unknown function (ip: 0x11d04b558)
do_respond at ./REPL.jl:646
unknown function (ip: 0x11d04a511)
do_call at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/interpreter.c:75
eval at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/interpreter.c:242
eval_body at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/interpreter.c:539
jl_toplevel_eval_body at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/interpreter.c:511
jl_toplevel_eval_flex at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/toplevel.c:571
jl_toplevel_eval_in at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/builtins.c:496
eval at ./boot.jl:235
jlcall_eval_17976 at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
run_interface at ./LineEdit.jl:1583
jlcall_run_interface_20033 at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
run_frontend at ./REPL.jl:945
run_repl at ./REPL.jl:180
unknown function (ip: 0x11cfff5d2)
_start at ./client.jl:413
jlcall__start_18910 at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
true_main at /usr/local/bin/julia (unknown line)
main at /usr/local/bin/julia (unknown line)
Allocations: 5293654 (Pool: 5292151; Big: 1503); GC: 9
Segmentation fault: 11
After using Transport
, there seem to be 3 additional reshape
methods defined. If those don't come from Transport itself, maybe one of its dependencies? What does [m.module for m in methods(reshape)]
give?
Okay, the other methods were defined by StaticArrays.
Can you reproduce the following (taken from a fresh REPL):
julia> using StaticArrays
julia> methods(reshape)
# 16 methods for generic function "reshape":
reshape(a::Array{T,N}, dims::Tuple{Vararg{Int64,N}}) where {N, T} in Base at array.jl:170
reshape(a::Array{T,N} where N, dims::Tuple{Vararg{Int64,N}}) where {N, T} in Base at array.jl:181
reshape(parent::AbstractArray, dims::Int64...) in Base at reshapedarray.jl:95
reshape(parent::AbstractArray, dims::Union{AbstractUnitRange, Int64}...) in Base at reshapedarray.jl:90
reshape(B::BitArray{N}, dims::Tuple{Vararg{Int64,N}}) where N in Base at bitarray.jl:477
reshape(B::BitArray, dims::Tuple{Vararg{Int64,N} where N}) in Base at bitarray.jl:479
reshape(a::SharedArray{T,N} where N, dims::Tuple{Vararg{Int64,N}}) where {T, N} in Base at sharedarray.jl:273
signal (11): Segmentation fault
while loading no file, in expression starting on line 0
show_datatype at ./show.jl:215
show at ./show.jl:211
unknown function (ip: 0x7f0738e68096)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
print at ./strings/io.jl:29
unknown function (ip: 0x7f0738e68046)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
#print_to_string#229 at ./strings/io.jl:98
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
jl_apply at /home/spowell/julia/src/julia.h:1424 [inlined]
jl_f__apply at /home/spowell/julia/src/builtins.c:426
#print_to_string at ./<missing>:0
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
argtype_decl at ./methodshow.jl:42
unknown function (ip: 0x7f0738e67a23)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
arg_decl_parts at ./methodshow.jl:61
#show#389 at ./methodshow.jl:98
unknown function (ip: 0x7f0738e662f2)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_invoke at /home/spowell/julia/src/gf.c:41
#show at ./<missing>:0
show_method_table at ./methodshow.jl:156
unknown function (ip: 0x7f0738e64f88)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
display at ./REPL.jl:122
unknown function (ip: 0x7f0738e64456)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
display at ./REPL.jl:125
unknown function (ip: 0x7f0738e64176)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
display at ./multimedia.jl:194
unknown function (ip: 0x7f0738e64032)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
do_call at /home/spowell/julia/src/interpreter.c:75
eval at /home/spowell/julia/src/interpreter.c:242
eval_body at /home/spowell/julia/src/interpreter.c:539
jl_toplevel_eval_body at /home/spowell/julia/src/interpreter.c:511
jl_toplevel_eval_flex at /home/spowell/julia/src/toplevel.c:571
jl_toplevel_eval_in at /home/spowell/julia/src/builtins.c:496
eval at ./boot.jl:235
unknown function (ip: 0x7f0768f4585f)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
print_response at ./REPL.jl:144
unknown function (ip: 0x7f0738e63848)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
print_response at ./REPL.jl:129
unknown function (ip: 0x7f0738e63258)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
do_respond at ./REPL.jl:646
unknown function (ip: 0x7f0738e61301)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
do_call at /home/spowell/julia/src/interpreter.c:75
eval at /home/spowell/julia/src/interpreter.c:242
eval_body at /home/spowell/julia/src/interpreter.c:539
jl_toplevel_eval_body at /home/spowell/julia/src/interpreter.c:511
jl_toplevel_eval_flex at /home/spowell/julia/src/toplevel.c:571
jl_toplevel_eval_in at /home/spowell/julia/src/builtins.c:496
eval at ./boot.jl:235
unknown function (ip: 0x7f0768f4585f)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
run_interface at ./LineEdit.jl:1583
unknown function (ip: 0x7f0768fa9e1f)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
run_frontend at ./REPL.jl:945
run_repl at ./REPL.jl:180
unknown function (ip: 0x7f0738e493f2)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
_start at ./client.jl:413
unknown function (ip: 0x7f0768f87b88)
jl_call_fptr_internal at /home/spowell/julia/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/spowell/julia/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/spowell/julia/src/gf.c:1933
unknown function (ip: 0x401df0)
unknown function (ip: 0x4015b2)
__libc_start_main at /build/glibc-bfm8X4/glibc-2.23/csu/../csu/libc-start.c:291
unknown function (ip: 0x401668)
Allocations: 4538091 (Pool: 4536746; Big: 1345); GC: 7
Segmentation fault (core dumped)
Yes,
using StaticArrays
methods(reshape)
crashes, both on 0.6.0 and master. Let's see why that might be...
This is weird, it's not even about showing one of the methods in StaticArrays:
julia> for m in methods(reshape)
print("at $(m.file):$(m.line) in $(m.module): ")
println(" $(m.sig)")
end
at array.jl:174 in Base: Tuple{Base.#reshape,Array{T,N},Tuple{Vararg{Int64,N}}} where T where N
at array.jl:185 in Base: Tuple{Base.#reshape,Array{T,N} where N,Tuple{Vararg{Int64,N}}} where T where N
at reshapedarray.jl:95 in Base: Tuple{Base.#reshape,AbstractArray,Vararg{Int64,N} where N}
at reshapedarray.jl:90 in Base: Tuple{Base.#reshape,AbstractArray,Vararg{Union{AbstractUnitRange, Int64},N} where N}
at bitarray.jl:483 in Base: Tuple{Base.#reshape,BitArray{N},Tuple{Vararg{Int64,N}}} where N
at bitarray.jl:485 in Base: Tuple{Base.#reshape,BitArray,Tuple{Vararg{Int64,N} where N}}
at sharedarray.jl:273 in Base: Tuple{Base.#reshape,SharedArray{T,N} where N,Tuple{Vararg{Int64,N}}} where N where T
at reshapedarray.jl:92 in Base: Tuple{Base.#reshape,AbstractArray,Tuple{Vararg{Int64,N}} where N}
at reshapedarray.jl:97 in Base: Tuple{Base.#reshape,AbstractArray,Tuple{Vararg{Union{Colon, Int64},N} where N}}
at reshapedarray.jl:91 in Base: Tuple{Base.#reshape,AbstractArray,Union{Tuple{Base.OneTo,Vararg{Base.OneTo,N} where N}, Tuple{Integer,Vararg{Integer,N} where N}}}
at reshapedarray.jl:96 in Base: Tuple{Base.#reshape,AbstractArray,Vararg{Union{Colon, Int64},N} where N}
at reshapedarray.jl:115 in Base: Tuple{Base.#reshape,AbstractArray{T,N},Val{N}} where N where T
at reshapedarray.jl:117 in Base: Tuple{Base.#reshape,AbstractArray,Val{N}} where N
at deprecated.jl:56 in Base: Tuple{Base.#reshape,AbstractArray,Type{Val{N}}} where N
julia> using StaticArrays
julia> for m in methods(reshape)
print("at $(m.file):$(m.line) in $(m.module): ")
println(" $(m.sig)")
end
at array.jl:174 in Base: Tuple{Base.#reshape,Array{T,N},Tuple{Vararg{Int64,N}}} where T where N
at array.jl:185 in Base: Tuple{Base.#reshape,Array{T,N} where N,Tuple{Vararg{Int64,N}}} where T where N
at reshapedarray.jl:95 in Base: Tuple{Base.#reshape,AbstractArray,Vararg{Int64,N} where N}
at reshapedarray.jl:90 in Base: Tuple{Base.#reshape,AbstractArray,Vararg{Union{AbstractUnitRange, Int64},N} where N}
at bitarray.jl:483 in Base: Tuple{Base.#reshape,BitArray{N},Tuple{Vararg{Int64,N}}} where N
at bitarray.jl:485 in Base: Tuple{Base.#reshape,BitArray,Tuple{Vararg{Int64,N} where N}}
at sharedarray.jl:273 in Base: Tuple{Base.#reshape,SharedArray{T,N} where N,Tuple{Vararg{Int64,N}}} where N where T
at reshapedarray.jl:92 in Base: Process 23141 stopped
* thread #1: tid = 23141, 0x00007fffed390feb sys-debug.so`julia_length_3423(#self#=<unavailable>, v=<unavailable>) + 107 at essentials.jl:284, name = 'julia-debug', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
The backtrace starts with
* frame #0: 0x00007fffed390feb sys-debug.so`julia_length_3423(#self#=<unavailable>, v=<unavailable>) + 107 at essentials.jl:284
frame #1: 0x00007fffeda17143 sys-debug.so`japi1_show_datatype_26888 [inlined] isempty + 19 at essentials.jl:289
frame #2: 0x00007fffeda17130 sys-debug.so`japi1_show_datatype_26888(#self#=<unavailable>, io=GenericIOBuffer @ 0x00007fffe8ebf0d0, x=0x00007fffee2f72e0) + 560 at show.jl:215
frame #3: 0x00007fffeda17974 sys-debug.so`japi1_show_26887(#self#=<unavailable>, io=GenericIOBuffer @ 0x00007fffe8ebf0d0, x=0x00007fffee2f72e0) + 132 at show.jl:211
and call jl_((void*) 0x00007fffee2f72e0)
works and produces Tuple{Vararg{Int64, N}} where N
, which is a UnionAll
, not a DataType
. So when show
ing the signature tuple and calling show
recursively on the third Tuple
parameter, the wrong method is being dispatched to.
Yep, there is something funny going on with dispatch here. Let's add an assertion to prevent all those nasty segfaults:
julia> using StaticArrays
julia> eval(Base, quote
function show(io::IO, x::DataType)
assert(ccall(:jl_typeof, Any, (Any,), x) == DataType)
show_datatype(io, x)
end
end)
Then
# 17 methods for generic function "reshape":
[1] reshape(a::Array{T,N}, dims::Tuple{Vararg{Int64,N}}) where {N, T} in Base at array.jl:174
[2] reshape(a::Array{T,N} where N, dims::Tuple{Vararg{Int64,N}}) where {N, T} in Base at array.jl:185
[3] reshape(parent::AbstractArray, dims::Int64...) in Base at reshapedarray.jl:95
[4] reshape(parent::AbstractArray, dims::Union{AbstractUnitRange, Int64}...) in Base at reshapedarray.jl:90
[5] reshape(B::BitArray{N}, dims::Tuple{Vararg{Int64,N}}) where N in Base at bitarray.jl:483
[6] reshape(B::BitArray, dims::Tuple{Vararg{Int64,N} where N}) in Base at bitarray.jl:485
[7] reshape(a::SharedArray{T,N} where N, dims::Tuple{Vararg{Int64,N}}) where {T, N} in Base at sharedarray.jl:273
[8] Error showing value of type Base.MethodList:
ERROR: AssertionError:
Stacktrace:
[1] assert at ./error.jl:81 [inlined]
[2] show(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::DataType) at ./REPL[2]:3
[3] print(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Type{T} where T) at ./strings/io.jl:29
[4] #print_to_string#240(::Base.ImmutableDict{Symbol,Any}, ::Function, ::Type{T} where T, ::Vararg{Type{T} where T,N} where N) at ./strings/io.jl:98
[5] (::Base.#kw##print_to_string)(::Array{Any,1}, ::Base.#print_to_string, ::Type{T} where T, ::Vararg{Type{T} where T,N} where N) at ./<missing>:0
[6] string_with_env(::Base.ImmutableDict{Symbol,Any}, ::Type{T} where T, ::Vararg{Type{T} where T,N} where N) at ./strings/io.jl:108
[7] argtype_decl(::Base.ImmutableDict{Symbol,Any}, ::Symbol, ::DataType, ::Int64, ::Int32, ::Bool) at ./methodshow.jl:42
[8] arg_decl_parts(::Method) at ./methodshow.jl:61
[9] #show#404(::Nullable{DataType}, ::Function, ::IOContext{Base.Terminals.TTYTerminal}, ::Method) at ./methodshow.jl:98
[10] (::Base.#kw##show)(::Array{Any,1}, ::Base.#show, ::IOContext{Base.Terminals.TTYTerminal}, ::Method) at ./<missing>:0
[11] show_method_table(::IOContext{Base.Terminals.TTYTerminal}, ::Base.MethodList, ::Int64, ::Bool) at ./methodshow.jl:16
...
And also
julia> [m.sig for m in methods(reshape)][1:8]
8-element Array{Type,1}:
Error showing value of type Array{Type,1}:
ERROR: AssertionError:
Stacktrace:
[1] assert at ./error.jl:81 [inlined]
[2] show(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::DataType) at ./REPL[2]:3
[3] show_datatype(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::DataType) at ./show.jl:229
[4] show(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::DataType) at ./REPL[2]:4
[5] #sprint#239(::IOContext{Base.Terminals.TTYTerminal}, ::Function, ::Int64, ::Function, ::Type{T} where T, ::Vararg{Type{T} where T,N} where N) at ./strings/io.jl:64
[6] (::Base.#kw##sprint)(::Array{Any,1}, ::Base.#sprint, ::Int64, ::Function, ::Type{T} where T, ::Vararg{Type{T} where T,N} where N) at ./<missing>:0
[7] alignment(::IOContext{Base.Terminals.TTYTerminal}, ::Type) at ./show.jl:1354
[8] alignment(::IOContext{Base.Terminals.TTYTerminal}, ::Array{Type,1}, ::Array{Int64,1}, ::Array{Int64,1}, ::Int64, ::Int64, ::Int64) at ./show.jl:1398
[9] print_matrix(::IOContext{Base.Terminals.TTYTerminal}, ::Array{Type,1}, ::String, ::String, ::String, ::String, ::String, ::String, ::Int64, ::Int64) at ./show.jl:1527
But:
julia> [m.sig for m in methods(reshape)][1:7]
7-element Array{Type,1}:
Tuple{Base.#reshape,Array{T,N},Tuple{Vararg{Int64,N}}} where T where N
Tuple{Base.#reshape,Array{T,N} where N,Tuple{Vararg{Int64,N}}} where T where N
Tuple{Base.#reshape,AbstractArray,Vararg{Int64,N} where N}
Tuple{Base.#reshape,AbstractArray,Vararg{Union{AbstractUnitRange, Int64},N} where N}
Tuple{Base.#reshape,BitArray{N},Tuple{Vararg{Int64,N}}} where N
Tuple{Base.#reshape,BitArray,Tuple{Vararg{Int64,N} where N}}
Tuple{Base.#reshape,SharedArray{T,N} where N,Tuple{Vararg{Int64,N}}} where N where T
julia> [m.sig for m in methods(reshape)][8]
Tuple{Base.#reshape,AbstractArray,Tuple{Vararg{Int64,N}} where N}
Turns out this can be reduced to the following:
julia> struct Foo{S, L} end
julia> Base.show(io::IO, ::Type{Foo{S}}) where {S} = print(io, "")
julia> Base.show(io::IO, ::Type{Foo{Tuple{L}, L}}) where {L} = print(io, "")
julia> methods(reshape)
# 14 methods for generic function "reshape":
[1] reshape(a::Array{T,N}, dims::Tuple{Vararg{Int64,N}}) where {N, T} in Base at array.jl:246
[2] reshape(a::Array{T,N} where N, dims::Tuple{Vararg{Int64,N}}) where {N, T} in Base at array.jl:257
[3] reshape(parent::AbstractArray, dims::Int64...) in Base at reshapedarray.jl:95
[4] reshape(parent::AbstractArray, dims::Union{Int64, AbstractUnitRange}...) in Base at reshapedarray.jl:90
[5] reshape(B::BitArray{N}, dims::Tuple{Vararg{Int64,N}}) where N in Base at bitarray.jl:487
[6] reshape(B::BitArray, dims::Tuple{Vararg{Int64,N} where N}) in Base at bitarray.jl:489
[7] reshape(a::SharedArray{T,N} where N, dims::Tuple{Vararg{Int64,N}}) where {T, N} in Base at sharedarray.jl:273
[8]
signal (11): Segmentation fault
# ...
Further ruduction
f(x::UnionAll) = UnionAll
f(x::DataType) = length(x.parameters)
f(Tuple{Vararg{Int64,N} where N})
f(Tuple{Vararg{Int64,N}} where N)
Also
julia> [Tuple{Vararg{Int64,N} where N},
Tuple{Vararg{Int64,N}} where N]
ERROR: MethodError: Cannot `convert` an object of type Type{Tuple{Vararg{Int64,N} where N}} to an object of type UnionAll
This may have arisen from a call to the constructor UnionAll(...),
since type constructors fall back to convert methods.
Stacktrace:
[1] setindex!(::Array{UnionAll,1}, ::Type{T} where T, ::Int64) at ./array.jl:806
[2] vect(::Type{Tuple{Vararg{Int64,N} where N}}, ::Vararg{Type{Tuple{Vararg{Int64,N} where N}},N} where N) at ./array.jl:96
I can see how it got confused not sure about the right solution, this is on a 4 day old master. Didn't check more recent version.
@JeffBezanson
Awesome job reducing the test case, @martinholters and @yuyichao . With that, it should be relatively easy to fix.
Most helpful comment
Turns out this can be reduced to the following: