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 on 0.7.0-alpha.0: compiler #27365

Closed
awllee opened this issue Jun 1, 2018 · 1 comment
Closed

Internal error on 0.7.0-alpha.0: compiler #27365

awllee opened this issue Jun 1, 2018 · 1 comment
Assignees
Labels
compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) kind:bug Indicates an unexpected problem or unintended behavior

Comments

@awllee
Copy link

awllee commented Jun 1, 2018

Here is a snippet that works in 0.6 but not 0.7.0-alpha.0. I certainly do not understand what is going on; to construct this MWE I focused on the fact that the conditional in M! appears to be essential. Also, julia does not crash; one can still call bar successfully after the internal error is reported.

mutable struct Float64Data
  x::Float64
  Float64Data() = new()
end

@inline function M!(data::Float64Data, i::Int64)
  if i == 1
    data.x = 0.0
  else
    data.x = data.x
  end
end

function foo()
  data = Float64Data()
  M!(data, 1)
end

function bar(i::Int64)
  data = Float64Data()
  M!(data, i)
end

foo() # no problem
bar(1) # Internal error: encountered unexpected error in runtime```

The error output is

`Internal error: encountered unexpected error in runtime:
BoundsError(a=Array{Any, (1,)}[Main.Float64Data], 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
jl_bounds_error_ints at /buildworker/worker/package_linux64/build/src/rtutils.c:187
getindex at ./array.jl:707
jfptr_getindex_234.clone_1 at /home/al17824/julia-latest/lib/julia/sys.so (unknown line)
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2140
val_for_def_expr at ./compiler/ssair/passes.jl:65
compute_value_for_use at ./compiler/ssair/passes.jl:102
getfield_elim_pass! at ./compiler/ssair/passes.jl:716
run_passes at ./compiler/ssair/driver.jl:173
optimize at ./compiler/optimize.jl:183
typeinf at ./compiler/typeinfer.jl:436
typeinf_frame at ./compiler/typeinfer.jl:96 [inlined]
typeinf_code at ./compiler/typeinfer.jl:191
typeinf_ext at ./compiler/typeinfer.jl:233
jfptr_typeinf_ext_12.clone_1 at /home/al17824/julia-latest/lib/julia/sys.so (unknown line)
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2140
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1540 [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:1778 [inlined]
jl_fptr_trampoline at /buildworker/worker/package_linux64/build/src/gf.c:1822
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2140
do_call at /buildworker/worker/package_linux64/build/src/interpreter.c:324
eval_value at /buildworker/worker/package_linux64/build/src/interpreter.c:416
eval_body at /buildworker/worker/package_linux64/build/src/interpreter.c:559
jl_interpret_toplevel_thunk_callback at /buildworker/worker/package_linux64/build/src/interpreter.c:798
unknown function (ip: 0xfffffffffffffffe)
unknown function (ip: 0x7f251ade974f)
unknown function (ip: 0xffffffffffffffff)
jl_interpret_toplevel_thunk at /buildworker/worker/package_linux64/build/src/interpreter.c:807
jl_toplevel_eval_flex at /buildworker/worker/package_linux64/build/src/toplevel.c:856
jl_parse_eval_all at /buildworker/worker/package_linux64/build/src/ast.c:852
jl_load at /buildworker/worker/package_linux64/build/src/toplevel.c:894
include at ./boot.jl:314 [inlined]
include_relative at ./loading.jl:1071
include at ./sysimg.jl:29
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2140
exec_options at ./client.jl:267
_start at ./client.jl:427
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2140
unknown function (ip: 0x401af8)
unknown function (ip: 0x401523)
__libc_start_main at /build/glibc-Cl5G7W/glibc-2.23/csu/../csu/libc-start.c:291
unknown function (ip: 0x4015c4)
`
@awllee
Copy link
Author

awllee commented Jun 1, 2018

This is probably related:

mutable struct Float64Data
  x::Float64
  Float64Data() = new()
end

function baz()
  data = Float64Data()
  return data.x
end

fd = Float64Data(); println(fd.x) # no problem

baz() # internal error

Although in this case one could argue that the code is requiring undefined memory to be accessed.

@Keno Keno added kind:bug Indicates an unexpected problem or unintended behavior compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) labels Jun 1, 2018
@Keno Keno self-assigned this Jun 1, 2018
Keno added a commit that referenced this issue Jun 3, 2018
For now, just bail out in this situation. There's a number of better
things we could do here. However, I want to avoid making #26764 worse
for now.

Fixes #27365
Keno added a commit that referenced this issue Jun 8, 2018
For now, just bail out in this situation. There's a number of better
things we could do here. However, I want to avoid making #26764 worse
for now.

Fixes #27365
Keno added a commit that referenced this issue Jun 8, 2018
For now, just bail out in this situation. There's a number of better
things we could do here. However, I want to avoid making #26764 worse
for now.

Fixes #27365
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/) kind:bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants