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 when running JuMP's tests #28444

Closed
mlubin opened this issue Aug 4, 2018 · 2 comments · Fixed by #30598
Closed

internal error when running JuMP's tests #28444

mlubin opened this issue Aug 4, 2018 · 2 comments · Fixed by #30598
Labels
bug Indicates an unexpected problem or unintended behavior compiler:optimizer Optimization passes (mostly in base/compiler/ssair/)

Comments

@mlubin
Copy link
Member

mlubin commented Aug 4, 2018

julia> versioninfo()
Julia Version 0.7.0-rc2.0
Commit 78540cba4c (2018-08-02 19:14 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i5-7300U CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, skylake)

When running JuMP's tests (current master, commit cd6457b6c0c82de339b30bbd747a3f1bac135b8b), the following internal error is printed:

Internal error: encountered unexpected error in runtime:
ErrorException("type Nothing has no field args")
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
jl_errorf at /buildworker/worker/package_linux64/build/src/rtutils.c:77
jl_field_index at /buildworker/worker/package_linux64/build/src/datatype.c:821
jl_f_getfield at /buildworker/worker/package_linux64/build/src/builtins.c:755
try_compute_fieldidx_expr at ./compiler/ssair/passes.jl:23
getfield_elim_pass! at ./compiler/ssair/passes.jl:720
run_passes at ./compiler/ssair/driver.jl:123
optimize at ./compiler/optimize.jl:162
typeinf at ./compiler/typeinfer.jl:35
typeinf_ext at ./compiler/typeinfer.jl:567
typeinf_ext at ./compiler/typeinfer.jl:604
jfptr_typeinf_ext_1.clone_1 at /home/mlubin/julia/julia-0.7.0-rc2/lib/julia/sys.so (unknown line)
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2165
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1538 [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:275
jl_compile_method_internal at /buildworker/worker/package_linux64/build/src/gf.c:1767 [inlined]
jl_fptr_trampoline at /buildworker/worker/package_linux64/build/src/gf.c:1811
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2165
macro expansion at /home/mlubin/.julia/dev/JuMP/test/derivatives.jl:40 [inlined]
macro expansion at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Test/src/Test.jl:1079 [inlined]
top-level scope at /home/mlubin/.julia/dev/JuMP/test/derivatives.jl:11
jl_fptr_trampoline at /buildworker/worker/package_linux64/build/src/gf.c:1812
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:825
jl_parse_eval_all at /buildworker/worker/package_linux64/build/src/ast.c:841
jl_load at /buildworker/worker/package_linux64/build/src/toplevel.c:865
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:2165
include at ./client.jl:398
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2165
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: 0x7f32773291df)
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:831
jl_parse_eval_all at /buildworker/worker/package_linux64/build/src/ast.c:841
jl_load at /buildworker/worker/package_linux64/build/src/toplevel.c:865
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:2165
include at ./client.jl:398
jl_fptr_trampoline at /buildworker/worker/package_linux64/build/src/gf.c:1812
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2165
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: 0x7f32734cc64f)
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:831
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:778
jl_toplevel_eval_in at /buildworker/worker/package_linux64/build/src/builtins.c:633
eval at ./boot.jl:319
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2165
macro expansion at ./logging.jl:317 [inlined]
exec_options at ./client.jl:229
_start at ./client.jl:432
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2165
jl_apply at /buildworker/worker/package_linux64/build/ui/../src/julia.h:1538 [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 /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
_start at /home/mlubin/julia/julia-0.7.0-rc2/bin/julia (unknown line)

This happens locally and also on travis (https://travis-ci.org/JuliaOpt/JuMP.jl/jobs/412077553#L796). The error appears to be ignored, it doesn't crash julia. (The tests proceed to fail at a later point.)

@JeffBezanson JeffBezanson added the compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) label Aug 4, 2018
@ararslan ararslan added the bug Indicates an unexpected problem or unintended behavior label Aug 5, 2018
@Keno
Copy link
Member

Keno commented Aug 6, 2018

This would happen if a use is discovered to be unused during the pass. I think it would be correct just to ignore the statement in that case:

        for use in defuse.uses
-            field = try_compute_fieldidx_expr(typ, )
+           stmt = ir[SSAValue(use)]
+           stmt === nothing && continue
+           field = try_compute_fieldidx_expr(typ, stmt)
            field === nothing && (ok = false; break)
            push!(fielddefuse[field].uses, use)
        end

and similarly for the loop before that. Does need a properly reduced test case though.

@ararslan ararslan mentioned this issue Aug 6, 2018
3 tasks
@Keno
Copy link
Member

Keno commented Aug 6, 2018

This is a fun one. There's a second bug here that makes this transformation apply even though it's not legal in the JuMP example. After fixing that, the following simple example reproduces the reported behavior:

mutable struct foo
    a::Int
    b::Int
end
function bar()
    a = foo(1, 2)
    c, d = a.a, a.b
    e = (c, d)
    e[1]
end

(doesn't fail on master though, because of the same legality check bug working in the opposite direction).

Keno added a commit that referenced this issue Aug 6, 2018
The legality check was using use counts after `finish(compact)` got
to delete, which made them inaccurate. Instead, take a copy of the
use counts before. Additionally, ignore any uses that got deleted
during `finish(compact)`. Fixes #28444.
ararslan pushed a commit that referenced this issue Aug 6, 2018
The legality check was using use counts after `finish(compact)` got
to delete, which made them inaccurate. Instead, take a copy of the
use counts before. Additionally, ignore any uses that got deleted
during `finish(compact)`. Fixes #28444.

(cherry picked from commit 0f3d586)
Keno added a commit that referenced this issue Aug 6, 2018
The legality check was using use counts after `finish(compact)` got
to delete, which made them inaccurate. Instead, take a copy of the
use counts before. Additionally, ignore any uses that got deleted
during `finish(compact)`. Fixes #28444.
Keno added a commit that referenced this issue Jan 5, 2019
PR #28478 moved the computation of the use counts before the finish call.
to fix #28444. However, the early parts of the finish call fixes up phi
node arguments, which fail to get counted if we look at use counts before
that fixup is performed. This causes #30594 where the only non-trivial use
is on the backedge of the phi and would thus incorrectly fail to get accounted
for. Fix that by taking the use count after phi fixup but before dce.
Keno added a commit that referenced this issue Jan 5, 2019
PR #28478 moved the computation of the use counts before the finish call.
to fix #28444. However, the early parts of the finish call fixes up phi
node arguments, which fail to get counted if we look at use counts before
that fixup is performed. This causes #30594 where the only non-trivial use
is on the backedge of the phi and would thus incorrectly fail to get accounted
for. Fix that by taking the use count after phi fixup but before dce.
Keno added a commit that referenced this issue Jan 6, 2019
PR #28478 moved the computation of the use counts before the finish call.
to fix #28444. However, the early parts of the finish call fixes up phi
node arguments, which fail to get counted if we look at use counts before
that fixup is performed. This causes #30594 where the only non-trivial use
is on the backedge of the phi and would thus incorrectly fail to get accounted
for. Fix that by taking the use count after phi fixup but before dce.
KristofferC pushed a commit that referenced this issue Jan 9, 2019
PR #28478 moved the computation of the use counts before the finish call.
to fix #28444. However, the early parts of the finish call fixes up phi
node arguments, which fail to get counted if we look at use counts before
that fixup is performed. This causes #30594 where the only non-trivial use
is on the backedge of the phi and would thus incorrectly fail to get accounted
for. Fix that by taking the use count after phi fixup but before dce.

(cherry picked from commit f8f2045)
KristofferC pushed a commit that referenced this issue Jan 11, 2019
PR #28478 moved the computation of the use counts before the finish call.
to fix #28444. However, the early parts of the finish call fixes up phi
node arguments, which fail to get counted if we look at use counts before
that fixup is performed. This causes #30594 where the only non-trivial use
is on the backedge of the phi and would thus incorrectly fail to get accounted
for. Fix that by taking the use count after phi fixup but before dce.

(cherry picked from commit f8f2045)
KristofferC pushed a commit that referenced this issue Feb 4, 2019
PR #28478 moved the computation of the use counts before the finish call.
to fix #28444. However, the early parts of the finish call fixes up phi
node arguments, which fail to get counted if we look at use counts before
that fixup is performed. This causes #30594 where the only non-trivial use
is on the backedge of the phi and would thus incorrectly fail to get accounted
for. Fix that by taking the use count after phi fixup but before dce.

(cherry picked from commit f8f2045)
KristofferC pushed a commit that referenced this issue Feb 4, 2019
PR #28478 moved the computation of the use counts before the finish call.
to fix #28444. However, the early parts of the finish call fixes up phi
node arguments, which fail to get counted if we look at use counts before
that fixup is performed. This causes #30594 where the only non-trivial use
is on the backedge of the phi and would thus incorrectly fail to get accounted
for. Fix that by taking the use count after phi fixup but before dce.

(cherry picked from commit f8f2045)
KristofferC pushed a commit that referenced this issue Feb 11, 2019
The legality check was using use counts after `finish(compact)` got
to delete, which made them inaccurate. Instead, take a copy of the
use counts before. Additionally, ignore any uses that got deleted
during `finish(compact)`. Fixes #28444.
KristofferC pushed a commit that referenced this issue Feb 11, 2019
PR #28478 moved the computation of the use counts before the finish call.
to fix #28444. However, the early parts of the finish call fixes up phi
node arguments, which fail to get counted if we look at use counts before
that fixup is performed. This causes #30594 where the only non-trivial use
is on the backedge of the phi and would thus incorrectly fail to get accounted
for. Fix that by taking the use count after phi fixup but before dce.

(cherry picked from commit f8f2045)
KristofferC pushed a commit that referenced this issue Feb 11, 2019
PR #28478 moved the computation of the use counts before the finish call.
to fix #28444. However, the early parts of the finish call fixes up phi
node arguments, which fail to get counted if we look at use counts before
that fixup is performed. This causes #30594 where the only non-trivial use
is on the backedge of the phi and would thus incorrectly fail to get accounted
for. Fix that by taking the use count after phi fixup but before dce.

(cherry picked from commit f8f2045)
KristofferC pushed a commit that referenced this issue Apr 20, 2019
PR #28478 moved the computation of the use counts before the finish call.
to fix #28444. However, the early parts of the finish call fixes up phi
node arguments, which fail to get counted if we look at use counts before
that fixup is performed. This causes #30594 where the only non-trivial use
is on the backedge of the phi and would thus incorrectly fail to get accounted
for. Fix that by taking the use count after phi fixup but before dce.

(cherry picked from commit f8f2045)
KristofferC pushed a commit that referenced this issue Feb 20, 2020
PR #28478 moved the computation of the use counts before the finish call.
to fix #28444. However, the early parts of the finish call fixes up phi
node arguments, which fail to get counted if we look at use counts before
that fixup is performed. This causes #30594 where the only non-trivial use
is on the backedge of the phi and would thus incorrectly fail to get accounted
for. Fix that by taking the use count after phi fixup but before dce.

(cherry picked from commit f8f2045)
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 compiler:optimizer Optimization passes (mostly in base/compiler/ssair/)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants