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

line number missing from stacktrace #14444

Closed
timotheecour opened this issue May 25, 2020 · 2 comments · Fixed by #21201
Closed

line number missing from stacktrace #14444

timotheecour opened this issue May 25, 2020 · 2 comments · Fixed by #21201
Assignees

Comments

@timotheecour
Copy link
Member

timotheecour commented May 25, 2020

originally reported here: Traceback missing line number - Nim forum
but the problem is frequent, annoying (makes debugging harder), and fixable.

Example

when true: # D20200524T202847
  var i: string
  i[10] = 'j'
  echo i

Current Output

/Users/timothee/git_clone/nim/timn/tests/nim/all/t10814.nim t10814
/Users/timothee/git_clone/nim/Nim_devel/lib/system/fatal.nim(49) sysFatal
Error: unhandled exception: index out of bounds, the container is empty [IndexDefect]

Expected Output

/Users/timothee/git_clone/nim/timn/tests/nim/all/t10814.nim t10814
=>
/Users/timothee/git_clone/nim/timn/tests/nim/all/t10814.nim(2) t10814

Additional Information

in more complex cases, the lack of line number would be more problematic, eg:

when defined case4:
  template bar(i) =
    i[10] = 'j' # <- stacktrace should show this line number

  proc fun() =
    var i: string
    bar(i)
  fun() # <- stacktrace only shows this line number
@mratsim
Copy link
Collaborator

mratsim commented May 25, 2020

templates don't stacktrace properly in general, they eat one line.

@timotheecour
Copy link
Member Author

templates don't stacktrace properly in general, they eat one line.

that's an unrelated issue, the line number is missing even without templates, eg:

when true: # example i gave in https://forum.nim-lang.org/t/6355#39311
  echo "ok0"
  var i = ""
  var u0 = 12
  echo "ok1"  ## <- line number points to here
  const u1 = 12
  var u2 = 12
  i[10] = 'j'
  echo i

For templates, I think we can also improve things (see timotheecour#259); the idea is to add nimfr_ + popFrame + goto to templates so that they appear as regular procs as far as stacktraces are concerned (controlled by a --stacktraceForTemplates + pushable pragma to localize it as this would be costly)

@ringabout ringabout self-assigned this Dec 29, 2022
ringabout added a commit that referenced this issue Dec 29, 2022
Araq pushed a commit that referenced this issue Dec 29, 2022
* fixes #14444; add `genLineDir` before raises

* add a test case

* fixes differently
survivorm pushed a commit to survivorm/Nim that referenced this issue Feb 28, 2023
…1201)

* fixes nim-lang#14444; add `genLineDir` before raises

* add a test case

* fixes differently
capocasa pushed a commit to capocasa/Nim that referenced this issue Mar 31, 2023
…1201)

* fixes nim-lang#14444; add `genLineDir` before raises

* add a test case

* fixes differently
narimiran pushed a commit that referenced this issue Apr 26, 2023
* fixes #14444; add `genLineDir` before raises

* add a test case

* fixes differently

(cherry picked from commit 705da9d)
narimiran pushed a commit that referenced this issue May 15, 2023
* fixes #14444; add `genLineDir` before raises

* add a test case

* fixes differently

(cherry picked from commit 705da9d)
narimiran pushed a commit that referenced this issue May 24, 2023
* fixes #14444; add `genLineDir` before raises

* add a test case

* fixes differently

(cherry picked from commit 705da9d)
bung87 pushed a commit to bung87/Nim that referenced this issue Jul 29, 2023
…1201)

* fixes nim-lang#14444; add `genLineDir` before raises

* add a test case

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

Successfully merging a pull request may close this issue.

3 participants