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

Illegal instruction in Julia 1.0.0/1.1.0 (but not in 0.7.0) #29468

Closed
oyamad opened this issue Oct 2, 2018 · 5 comments
Closed

Illegal instruction in Julia 1.0.0/1.1.0 (but not in 0.7.0) #29468

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

Comments

@oyamad
Copy link

oyamad commented Oct 2, 2018

(Initially posted in QuantEcon/GameTheory.jl#92)

Apologies if already known, but the following code leads to "Illegal instruction: 4" with Julia 1.0.0 and 1.1.0 (Nightly), but not with 0.7.0:

struct A{N,T}
    arr::Array{T,N}
end

struct B{N,T}
    as::NTuple{N,A{N,T}}
end

B(as::A{N,T}...) where {N,T} = B(as)
a1 = A(zeros(2, 2))
a2 = A(zeros(2, 2))
B(a1, a2)
Unreachable reached at 0x108a94186

signal (4): Illegal instruction: 4
in expression starting at no file:0
Type at ./REPL[3]:1
jl_fptr_trampoline at /Users/osx/buildbot/slave/package_osx64/build/src/gf.c:1829
do_call at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:324
eval_stmt_value at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:363 [inlined]
eval_body at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:686
jl_interpret_toplevel_thunk_callback at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:799
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x114d65a4f)
unknown function (ip: 0xffffffffffffffff)
jl_interpret_toplevel_thunk at /Users/osx/buildbot/slave/package_osx64/build/src/interpreter.c:808
jl_toplevel_eval_flex at /Users/osx/buildbot/slave/package_osx64/build/src/toplevel.c:787
jl_toplevel_eval_in at /Users/osx/buildbot/slave/package_osx64/build/src/builtins.c:622
eval at ./boot.jl:319
eval_user_input at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:85
macro expansion at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:117 [inlined]
#28 at ./task.jl:259
jl_apply at /Users/osx/buildbot/slave/package_osx64/build/src/./julia.h:1536 [inlined]
start_task at /Users/osx/buildbot/slave/package_osx64/build/src/task.c:268
Allocations: 1032878 (Pool: 1032627; Big: 251); GC: 1
Illegal instruction: 4
julia> versioninfo()
Julia Version 1.0.0
Commit 5d4eaca0c9 (2018-08-08 20:58 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Xeon(R) CPU E5-1650 v2 @ 3.50GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, ivybridge)
julia> versioninfo()
Julia Version 1.1.0-DEV.352
Commit 4851fab9b4 (2018-10-01 13:53 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Xeon(R) CPU E5-1650 v2 @ 3.50GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, ivybridge)
@SimonDanisch
Copy link
Contributor

Maybe: #25430 #29066
Nice MWE, I can reproduce! :)

@SimonDanisch
Copy link
Contributor

   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.1.0-DEV.365 (2018-10-02)
 _/ |\__'_|_|_|\__'_|  |  jb/fix29269/67c5f6e317 (fork: 4 commits, 0 days)
|__/                   |

@JeffBezanson this still runs into the error even on your branch (I merged master into the branch, just in case that messes things up?)

@SimonDanisch
Copy link
Contributor

I checked 0.7 as well:

@vtjnash vtjnash added the types and dispatch Types, subtyping and method dispatch label Oct 2, 2018
@vtjnash
Copy link
Sponsor Member

vtjnash commented Oct 2, 2018

dissected it to this type-intersection bug:

julia> struct A{N}; end;

julia> typeintersect(Tuple{Vararg{A{N}, N}} where N,
                     Tuple{A{2}, Vararg{A{2}}})
Union{} # bad

julia> typeintersect(Tuple{Vararg{A{N}, N}} where N,
                     Tuple{Vararg{A{2}}})
Tuple{A{2}, A{2}} # more correct

Unrelated to the crash, I also noticed that the given second answer is actually wrong also. The correct answer is:

Union{Tuple{}, Tuple{A{2}, A{2}}}

since N=0 is also a valid solution to the above constraints.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Oct 2, 2018

(note this worked / didn't crash in v0.7 because we inhibited inference of the deprecated construct-to-convert method signature, and not a new type system or dispatch regression).

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

4 participants