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

Crash when printing array #26929

Closed
nalimilan opened this issue Apr 29, 2018 · 3 comments
Closed

Crash when printing array #26929

nalimilan opened this issue Apr 29, 2018 · 3 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@nalimilan
Copy link
Member

It's been noted at #26927 that the following code makes Julia crash. The convert method is needed to be able to create the array (else a MethodError is thrown).

julia> Base.convert(::Type{Union{Missing, Nothing, T}}, x::Any) where {T} = convert(T, x)

julia> x = [missing, nothing, Some(nothing), Some(missing)];

julia> x
4-element Array{Union{Missing, Nothing, Some{Union{Missing, Nothing}}},1}:
 missing      
 nothing      
 
signal (11): Segmentation fault
in expression starting at no file:0
CreateSub at /home/milan/Dev/julia/usr/include/llvm/IR/IRBuilder.h:800
[...]
@nalimilan nalimilan added the bug Indicates an unexpected problem or unintended behavior label Apr 29, 2018
@fisiognomico
Copy link
Contributor

fisiognomico commented May 5, 2018

I replied the bugged code, by shuffling the array elements some other combinations still segfault, but others give a more more interesting error message

julia> x = [Some(nothing), Some(missing), nothing, missing];
ERROR: MethodError: promote_rule(::Type{Union{Missing, Some{Missing}, Nothing}}, ::Type{Some{Nothing}}) is ambiguous. Candidates:
  promote_rule(::Type{Union{Missing, S}}, ::Type{T}) where {T, S} in Base at missing.jl:29
  promote_rule(::Type{Union{Nothing, S}}, ::Type{T}) where {T, S} in Base at missing.jl:29
Possible fix, define
  promote_rule(::Type{Union{Missing, Nothing}}, ::Type{T})
Stacktrace:
 [1] promote_type(::Type{Some{Nothing}}, ::Type{Union{Missing, Some{Missing}, Nothing}}) at ./promotion.jl:220
 [2] promote_typeof(::Some{Nothing}, ::Some{Missing}, ::Vararg{Any,N} where N) at ./promotion.jl:263
 [3] vect(::Some{Nothing}, ::Vararg{Any,N} where N) at ./array.jl:103
 [4] top-level scope

julia> x
2-element Array{Some{Union{Missing, Nothing}},1}:
 nothing
 missing

julia> x = [missing, Some(nothing), Some(missing), nothing];
ERROR: MethodError: convert(::Type{Union{Missing, Nothing, Some{Union{Missing, Nothing}}}}, ::Some{Nothing}) is ambiguous. Candida
tes:
  convert(::Type{Union{Missing, T}}, x) where T in Base at missing.jl:39
  convert(::Type{Union{Nothing, T}}, x) where T in Base at some.jl:21
Possible fix, define
  convert(::Type{Union{Missing, Nothing}}, ::Any)
Stacktrace:
 [1] setindex!(::Array{Union{Missing, Nothing, Some{Union{Missing, Nothing}}},1}, ::Some{Nothing}, ::Int64) at ./array.jl:705
 [2] copyto!(::Array{Union{Missing, Nothing, Some{Union{Missing, Nothing}}},1}, ::Tuple{Missing,Some{Nothing},Some{Missing},Nothin
g}) at ./abstractarray.jl:622
 [3] vect(::Missing, ::Vararg{Any,N} where N) at ./array.jl:106
 [4] top-level scope

julia> x = [nothing, missing, Some(nothing), Some(missing)];
ERROR: MethodError: convert(::Type{Union{Missing, Nothing, Some{Union{Missing, Nothing}}}}, ::Some{Nothing}) is ambiguous. Candida
tes:
  convert(::Type{Union{Missing, T}}, x) where T in Base at missing.jl:39
  convert(::Type{Union{Nothing, T}}, x) where T in Base at some.jl:21
Possible fix, define
  convert(::Type{Union{Missing, Nothing}}, ::Any)
Stacktrace:
 [1] setindex!(::Array{Union{Missing, Nothing, Some{Union{Missing, Nothing}}},1}, ::Some{Nothing}, ::Int64) at ./array.jl:705
 [2] copyto!(::Array{Union{Missing, Nothing, Some{Union{Missing, Nothing}}},1}, ::Tuple{Nothing,Missing,Some{Nothing},Some{Missing
}}) at ./abstractarray.jl:622
 [3] vect(::Nothing, ::Vararg{Any,N} where N) at ./array.jl:106
 [4] top-level scope

@JeffBezanson
Copy link
Member

I can't reproduce the crash.

@nalimilan
Copy link
Member Author

Cool, looks like it's been fixed recently (since May 5) on master.

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
Projects
None yet
Development

No branches or pull requests

3 participants