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

incorrect line number reported for index out of range error #922

Closed
mlubin opened this issue Jun 9, 2012 · 5 comments · Fixed by #13491
Closed

incorrect line number reported for index out of range error #922

mlubin opened this issue Jun 9, 2012 · 5 comments · Fixed by #13491
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior regression Regression in behavior compared to a previous version

Comments

@mlubin
Copy link
Member

mlubin commented Jun 9, 2012

If you run:

function foo()
    x = ones(10)
    print("first access\n")
    x[1]
    print("second access\n")
    x[20]
end
foo()

the result is

first access
second access
in foo: arrayref: index out of range
 in foo at none:4

Note the line number is incorrect. As in #900, this isn't helpful when trying to debug :)

@JeffBezanson
Copy link
Member

Looking in to this. So far it seems to happen on x86/64 but not 32-bit. Disabling LLVM's CFG simplification pass also makes the problem go away (at the cost of some performance). Not sure if that is an LLVM issue or has to do with how I'm using it.

@timholy
Copy link
Member

timholy commented Nov 29, 2012

I think it's Christmas early this year. This will help a lot.

@JeffBezanson
Copy link
Member

@vtjnash The BoundsError improvement seems to have broken this.

JeffBezanson added a commit that referenced this issue Sep 25, 2015
JeffBezanson added a commit that referenced this issue Sep 25, 2015
see e.g. #922

(cherry picked from commit 35c5234)
@vtjnash
Copy link
Member

vtjnash commented Sep 25, 2015

it seems this can be a pretty tough optimization to avoid, since llvm seems to detect the common sub-sequence and remove it (I don't know what pass is doing this, however):

oob1:                                             ; preds = %idxend
  %25 = alloca i64, align 8
  store i64 20, i64* %25, align 8
  call void @jl_bounds_error_ints(%jl_value_t* %20, i64* %25, i64 1)
  unreachable
oob:                                              ; preds = %top
  %17 = alloca i64, align 8
  store i64 1, i64* %17, align 8
  call void @jl_bounds_error_ints(%jl_value_t* %12, i64* %17, i64 1)
  unreachable
Source line: 4
L319:   movq    %rsp, %rax
    leaq    -16(%rax), %rsi
    movq    %rsi, %rsp
    movq    $1, -16(%rax)
    jmpq    L360
Source line: 6
L342:   movq    %rsp, %rax
    leaq    -16(%rax), %rsi
    movq    %rsi, %rsp
    movq    $20, -16(%rax)
Source line: 4
L360:   movabsq $jl_bounds_error_ints, %rax
    movl    $1, %edx
    callq   *%rax

ihnorton added a commit to ihnorton/julia that referenced this issue Oct 3, 2015
@vtjnash
Copy link
Member

vtjnash commented Oct 7, 2015

this behavior in llvm can be "corrected" at it's source by turning off this optimization in the FPM http://llvm.org/docs/doxygen/html/CodeGen_2Passes_8h_source.html#l00160

(or with a command line flag: JULIA_LLVM_ARGS=-enable-tail-merge=0 ../usr/bin/julia-debug)

vtjnash added a commit that referenced this issue Oct 7, 2015
@vtjnash vtjnash mentioned this issue Oct 7, 2015
vtjnash added a commit that referenced this issue Oct 7, 2015
skumagai pushed a commit to skumagai/julia that referenced this issue Oct 9, 2015
ihnorton added a commit that referenced this issue Oct 31, 2015
ref #922 and 35c5234

(cherry picked from commit 99ee2ff)
ref #13431
vtjnash added a commit that referenced this issue Nov 29, 2015
…ks around this issue

(cherry picked from commit af81d6c)
tkelman added a commit that referenced this issue Dec 2, 2015
… old hacks around this issue"

This reverts commit b8a6d77.
tkelman pushed a commit that referenced this issue Mar 13, 2016
…ks around this issue

(cherry picked from commit af81d6c)
ref #13491
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 regression Regression in behavior compared to a previous version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants