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

Internal error in optimizer #26729

Closed
haampie opened this issue Apr 6, 2018 · 3 comments
Closed

Internal error in optimizer #26729

haampie opened this issue Apr 6, 2018 · 3 comments
Labels
compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) needs tests Unit tests are required for this change

Comments

@haampie
Copy link
Contributor

haampie commented Apr 6, 2018

Here's a stripped down version of some code:

struct Less{O}
    is_less::O
end

struct By{T,O}
    by::T
    is_less::O
end

struct Reverse{O}
    is_less::O
end

function get_order(by = identity, func = isless, rev = false)
    ord = By(by, Less(func))
    rev ? Reverse(ord) : ord
end

get_order_kwargs(; by = identity, func = isless, rev = false) = get_order(by, func, rev)

Running the last function throws:

julia> get_order_kwargs()
Internal error: encountered unexpected error in runtime:
BoundsError(a=Core.Compiler.BitArray{1}(chunks=Array{UInt64, (1,)}[0x0000000000000000], len=1, dims=(139630074742768,)), i=(2,))
rec_backtrace at /buildworker/worker/package_linux64/build/src/stackwalk.c:94
record_backtrace at /buildworker/worker/package_linux64/build/src/task.c:246
jl_throw at /buildworker/worker/package_linux64/build/src/task.c:577
throw_boundserror at ./abstractarray.jl:467
checkbounds at ./abstractarray.jl:432 [inlined]
setindex! at ./bitarray.jl:644 [inlined]
split_struct_alloc! at ./compiler/optimize.jl:3178
optimize_value! at ./compiler/optimize.jl:4085
alloc_elim_pass! at ./compiler/optimize.jl:4109
optimize at ./compiler/optimize.jl:318
typeinf at ./compiler/typeinfer.jl:436
typeinf_edge at ./compiler/typeinfer.jl:137
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2167
abstract_call_method at ./compiler/abstractinterpretation.jl:281
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2167
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:78
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2167
abstract_call at ./compiler/abstractinterpretation.jl:669
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2167
abstract_eval_call at ./compiler/abstractinterpretation.jl:698
abstract_eval at ./compiler/abstractinterpretation.jl:770
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2167
abstract_interpret at ./compiler/abstractinterpretation.jl:887
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2167
typeinf_work at ./compiler/typeinfer.jl:276
typeinf at ./compiler/typeinfer.jl:407
typeinf_frame at ./compiler/typeinfer.jl:96 [inlined]
typeinf_code at ./compiler/typeinfer.jl:190
jfptr_typeinf_code_113.clone_1 at /m/home/home8/83/user/data/Downloads/julia-de26816a74/lib/julia/sys.so (unknown line)
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2167
typeinf_ext at ./compiler/typeinfer.jl:232
jfptr_typeinf_ext_12.clone_1 at /m/home/home8/83/user/data/Downloads/julia-de26816a74/lib/julia/sys.so (unknown line)
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2167
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1527 [inlined]
jl_apply_with_saved_exception_state at /buildworker/worker/package_linux64/build/src/rtutils.c:257
jl_type_infer at /buildworker/worker/package_linux64/build/src/gf.c:274
jl_compile_method_internal at /buildworker/worker/package_linux64/build/src/gf.c:1793 [inlined]
jl_fptr_trampoline at /buildworker/worker/package_linux64/build/src/gf.c:1837
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2167
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:324
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:396
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:546
jl_interpret_toplevel_thunk_callback at /buildworker/worker/package_linux64/build/src/interpreter.c:759
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x7efe292bc54f)
unknown function (ip: 0xffffffffffffffff)
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:768
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:849
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/builtins.c:624
eval at ./boot.jl:309 [inlined]
eval at /buildworker/worker/package_linux64/build/usr/share/julia/site/v0.7/REPL/src/REPL.jl:5
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2167
eval_user_input at /buildworker/worker/package_linux64/build/usr/share/julia/site/v0.7/REPL/src/REPL.jl:85
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2167
macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/site/v0.7/REPL/src/REPL.jl:116 [inlined]
#28 at ./event.jl:92
jl_fptr_trampoline at /buildworker/worker/package_linux64/build/src/gf.c:1838
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2167
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1527 [inlined]
start_task at /buildworker/worker/package_linux64/build/src/task.c:268
unknown function (ip: 0xffffffffffffffff)
By{typeof(identity),Less{typeof(isless)}}(identity, Less{typeof(isless)}(isless))

Does not throw when I run get_order(). When I define get_order without the branch things are fine as well:

function get_order(by = identity, func = isless, rev = false)
    ord = By(by, Less(func))
    Reverse(ord)
end

julia> get_order_kwargs()
Reverse{By{typeof(identity),Less{typeof(isless)}}}(By{typeof(identity),Less{typeof(isless)}}(identity, Less{typeof(isless)}(isless)))

Version:

julia> versioninfo()
Julia Version 0.7.0-DEV.4775
Commit de26816a74 (2018-04-06 06:54 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E3-1230 v5 @ 3.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, skylake)
Environment:
@JeffBezanson JeffBezanson added the compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) label Apr 6, 2018
@Keno
Copy link
Member

Keno commented Apr 6, 2018

Works with the new optimizer ;).... I'll show myself out 🚪.

@haampie
Copy link
Contributor Author

haampie commented May 15, 2018

So maybe this can now be closed since we have #27087 :)

@fredrikekre
Copy link
Member

Perhaps worth adding the example here as a test?

@StefanKarpinski StefanKarpinski added the needs tests Unit tests are required for this change label May 15, 2018
@StefanKarpinski StefanKarpinski added this to the 1.0.x milestone May 15, 2018
JeffBezanson added a commit that referenced this issue Sep 12, 2018
Fixed by the new optimizer. This closes #26729.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) needs tests Unit tests are required for this change
Projects
None yet
Development

No branches or pull requests

5 participants