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

another bug which crashes julia 1.0 and latest nightly 1.1.0 #29208

Closed
jmichel7 opened this issue Sep 15, 2018 · 2 comments
Closed

another bug which crashes julia 1.0 and latest nightly 1.1.0 #29208

jmichel7 opened this issue Sep 15, 2018 · 2 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior types and dispatch Types, subtyping and method dispatch

Comments

@jmichel7
Copy link

put the following in a file bug.jl (it is an extract from code for multivariate polynomials which is reduced to a point where it is a bit nonsensical)

function Base.merge(a::Vector{Pair{K,V}},
                    b::Vector{Pair{K,V}})::Vector{Pair{K,V}} where K where V
   vcat(a,b)
end

struct Monomial{T}
  d::Vector{Pair{Symbol,T}}
end

struct Polynomial{T,N}
 d::Vector{Pair{Monomial{N},T}}
end

function Base.promote(a::Polynomial{T},b::Polynomial{T1}) where T where T1
  T2=promote_type(T,T1)
  if T2!=T  a=Polynomial([m=>convert(T2,c) for (m,c) in a.d]) end
  if T2!=T1 b=Polynomial([m=>convert(T2,c) for (m,c) in b.d]) end
  a,b
end

function bug(a::Polynomial, b::Polynomial)
  (a,b)=promote(a,b)
  u=merge(a.d,b.d)
end

a=Polynomial([Monomial([:a=>1])=>1])
u=Polynomial([m=>1//2*c for (m,c) in a.d])
bug(a,u)

then julia bug.jl gives:

Unreachable reached at 0x7f11c8a836a1

signal (4): Instruction non permise
in expression starting at /home/jmichel/julia/Bug.jl:31
bug at /home/jmichel/julia/Bug.jl:26
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
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:324
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:428
eval_stmt_value at /buildworker/worker/package_linux64/build/src/interpreter.c:363 [inlined]
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:686
jl_interpret_toplevel_thunk_callback at /buildworker/worker/package_linux64/build/src/interpreter.c:799
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x7f11d3b312cf)
unknown function (ip: 0xffffffffffffffff)
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:808
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:787
jl_parse_eval_all at /buildworker/worker/package_linux64/build/src/ast.c:838
jl_load at /buildworker/worker/package_linux64/build/src/toplevel.c:821
include at ./boot.jl:317 [inlined]
include_relative at ./loading.jl:1038
include at ./sysimg.jl:29
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2182
exec_options at ./client.jl:229
_start at ./client.jl:421
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2182
jl_apply at /buildworker/worker/package_linux64/build/ui/../src/julia.h:1536 [inlined]
true_main at /buildworker/worker/package_linux64/build/ui/repl.c:112
main at /buildworker/worker/package_linux64/build/ui/repl.c:233
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_start at /home/jmichel/julia-1.0.0/bin/julia (unknown line)
Allocations: 1003172 (Pool: 1002962; Big: 210); GC: 1
Instruction non permise (core dumped)

@JeffBezanson JeffBezanson self-assigned this Sep 16, 2018
@JeffBezanson JeffBezanson added the types and dispatch Types, subtyping and method dispatch label Sep 16, 2018
@JeffBezanson
Copy link
Member

Boils down to this incorrect type intersection:

julia> T = Tuple{Vector{Pair{K,V}}, Vector{Pair{K,V}}} where K where V
Tuple{Array{Pair{K,V},1},Array{Pair{K,V},1}} where K where V

julia> A = Array{Pair{Monomial{_2},_1},1} where _2 where _1
Array{Pair{Monomial{_2},_1},1} where _2 where _1

julia> B = Array{Pair{Monomial{Int64},Rational{Int64}},1}
Array{Pair{Monomial{Int64},Rational{Int64}},1}

julia> typeintersect(T, Tuple{A,B})
Union{}

It works if the UnionAlls are moved outside Tuple{A,B}.

@JeffBezanson JeffBezanson added the bug Indicates an unexpected problem or unintended behavior label Sep 16, 2018
@JeffBezanson
Copy link
Member

Fixed by #29380

KristofferC pushed a commit that referenced this issue Sep 30, 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 types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

No branches or pull requests

2 participants