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

get_stacktrace overwrites line number when inside a for loop: #163

Open
markmeeus opened this issue Sep 28, 2023 · 0 comments
Open

get_stacktrace overwrites line number when inside a for loop: #163

markmeeus opened this issue Sep 28, 2023 · 0 comments

Comments

@markmeeus
Copy link
Contributor

Give this script

print("line1")
for i=1,10 do    
    print("line3")
    noSuchFunction()
end

The call to nuSuchFunction() throws an error, at which point the luerl stack looks like this:

[
   {:call_frame, nil, [], [{1}, {[]}], [:not_used, :not_used],
    [:pop, :block_close],
    [
      [
        {:nfor_loop, 2, 10, 1,
         [
           {:block_open, 1, 0},
           {:store_lvar, 1, 1},
           {:current_line, 3, "-no-file-"},
           {:push_gvar, "print"},
           {:push_last_lit, "line3"},
           {:pop_args, 1},
           :fcall,
           :pop,
           {:current_line, 4, "-no-file-"},
           {:push_gvar, "noSuchFunction"},
           {:pop_args, 0},
           :fcall,
           :pop,
           :block_close
         ]},
        {:return, 0}
      ]
    ]},
   {:current_line, 4, "-no-file-"},
   {:loop_frame, [{[]}], [], [:not_used], [return: 0], []},
   {:current_line, 2, "-no-file-"},
   {:call_frame, {:funref, 0, []}, [], [], [], [], []}
 ]

however, the call to get_stacktrace returns:

[
  {nil, [], [file: "-no-file-", line: 1]},
  {"-no-name-", [], [file: "-no-file-", line: 2]}
]

I was expecting the second stack trace line number to be 4 (where the error is thrown), not 2

I think this behavior is caused by the implementation of do_stackframe. The loop_frame is ignored there, I think they should either become a stack trace line because otherwise one of the current_line instructions is lost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant