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

Useful stacktraces with gc:orc #19491

Closed
johnnovak opened this issue Feb 5, 2022 · 6 comments
Closed

Useful stacktraces with gc:orc #19491

johnnovak opened this issue Feb 5, 2022 · 6 comments

Comments

@johnnovak
Copy link
Contributor

Nim 1.6.0 doesn't seem to provide proper stacktraces when certain types of runtime errors are encountered (seems like Defects are behaving like this).

Observe the difference between what's printed out when using gc:orc vs gc:refc.

The lack of proper stacktraces is a big deal not only during development (not everybody is happy to use a debugger all the time), but especially for production applications where you want to collect crash logs with useful stacktraces from users who ran into problems. Therefore, using ORC/ARC is not an option for me until we get proper stacktraces like with the default refc implementation.

gc:orc

Hint: gc: orc; opt: none (DEBUG BUILD, `-d:release` generates faster code)
291966 lines; 11.496s; 898.441MiB peakmem; proj: src/main; out: D:\Work\Code\gridmonger\gridmonger.exe [SuccessX]
Hint: D:\Work\Code\gridmonger\gridmonger.exe  [Exec]
D:\Work\Code\gridmonger\src\main.nim(8456Error: unhandled exception: value out of range: -1 notin 0 .. 9223372036854775807 [RangeDefect]
Error: execution of an external program failed: 'D:\Work\Code\gridmonger\gridmonger.exe '

gc:refc

Hint: gc: refc; opt: none (DEBUG BUILD, `-d:release` generates faster code)
293073 lines; 12.317s; 815.203MiB peakmem; proj: src/main; out: D:\Work\Code\gridmonger\gridmonger.exe [SuccessX]
Hint: D:\Work\Code\gridmonger\gridmonger.exe  [Exec]
D:\Work\Code\gridmonger\src\main.nim(8456) main
D:\Work\Code\gridmonger\src\main.nim(8414) main
D:\Work\Code\gridmonger\src\csdwindow.nim(516) renderFrame
D:\Work\Code\gridmonger\src\main.nim(8298) :anonymous
D:\Work\Code\gridmonger\src\main.nim(7863) renderFrame
D:\Work\Code\gridmonger\src\main.nim(7724) renderUI
D:\Work\Code\gridmonger\src\main.nim(6279) renderLevel
D:\Work\Code\gridmonger\src\drawlevel.nim(2731) drawLevel
D:\Work\Code\gridmonger\src\drawlevel.nim(520) drawCellCoords
D:\Work\Code\gridmonger\src\utils.nim(105) formatRowCoord
C:\dev\nim-1.6.0-x64\lib\system\fatal.nim(53) sysFatal
[[reraised from:
D:\Work\Code\gridmonger\src\main.nim(8456) main
D:\Work\Code\gridmonger\src\main.nim(8451) main
]]
Error: unhandled exception: value out of range: -1 notin 0 .. 9223372036854775807 [RangeDefect]
Error: execution of an external program failed: 'D:\Work\Code\gridmonger\gridmonger.exe '
@Araq
Copy link
Member

Araq commented Feb 5, 2022

This is supposed to work. Can you provide a test case?

@johnnovak
Copy link
Contributor Author

johnnovak commented Feb 5, 2022

There you go, wasn't hard. It would be probably a good idea to add a unit test for this for the future.

test.nim

proc foo() =
  let x = -1
  discard x.Natural

proc main() =
  foo()

main()

gc:refc

D:\Work\Code\gridmonger>nim c -r -f --gc:refc test.nim
Hint: used config file 'C:\dev\nim-1.6.0-x64\config\nim.cfg' [Conf]
Hint: used config file 'C:\dev\nim-1.6.0-x64\config\config.nims' [Conf]
.........................................................
CC: stdlib_digitsutils.nim
CC: stdlib_assertions.nim
CC: stdlib_dollars.nim
CC: stdlib_io.nim
CC: stdlib_system.nim
CC: test.nim
Hint:  [Link]
Hint: gc: refc; opt: none (DEBUG BUILD, `-d:release` generates faster code)
26572 lines; 1.589s; 31.562MiB peakmem; proj: D:\Work\Code\gridmonger\test.nim; out: D:\Work\Code\gridmonger\test.exe [SuccessX]
Hint: D:\Work\Code\gridmonger\test.exe  [Exec]
D:\Work\Code\gridmonger\test.nim(8) test
D:\Work\Code\gridmonger\test.nim(6) main
D:\Work\Code\gridmonger\test.nim(3) foo
C:\dev\nim-1.6.0-x64\lib\system\fatal.nim(53) sysFatal
Error: unhandled exception: value out of range: -1 notin 0 .. 9223372036854775807 [RangeDefect]
Error: execution of an external program failed: 'D:\Work\Code\gridmonger\test.exe '

gc:arc

D:\Work\Code\gridmonger>nim c -r -f --gc:arc test.nim
Hint: used config file 'C:\dev\nim-1.6.0-x64\config\nim.cfg' [Conf]
Hint: used config file 'C:\dev\nim-1.6.0-x64\config\config.nims' [Conf]
.......................................................
CC: stdlib_digitsutils.nim
CC: stdlib_dollars.nim
CC: stdlib_io.nim
CC: stdlib_system.nim
CC: test.nim
Hint:  [Link]
Hint: gc: arc; opt: none (DEBUG BUILD, `-d:release` generates faster code)
24913 lines; 1.503s; 25.445MiB peakmem; proj: D:\Work\Code\gridmonger\test.nim; out: D:\Work\Code\gridmonger\test.exe [SuccessX]
Hint: D:\Work\Code\gridmonger\test.exe  [Exec]
D:\Work\Code\gridmonger\test.nim(8Error: unhandled exception: value out of range: -1 notin 0 .. 9223372036854775807 [RangeDefect]
Error: execution of an external program failed: 'D:\Work\Code\gridmonger\test.exe '

gc:orc

D:\Work\Code\gridmonger>nim c -r -f --gc:orc test.nim
Hint: used config file 'C:\dev\nim-1.6.0-x64\config\nim.cfg' [Conf]
Hint: used config file 'C:\dev\nim-1.6.0-x64\config\config.nims' [Conf]
.........................................................
CC: stdlib_digitsutils.nim
CC: stdlib_dollars.nim
CC: stdlib_io.nim
CC: stdlib_system.nim
CC: test.nim
Hint:  [Link]
Hint: gc: orc; opt: none (DEBUG BUILD, `-d:release` generates faster code)
25465 lines; 1.547s; 31.641MiB peakmem; proj: D:\Work\Code\gridmonger\test.nim; out: D:\Work\Code\gridmonger\test.exe [SuccessX]
Hint: D:\Work\Code\gridmonger\test.exe  [Exec]
D:\Work\Code\gridmonger\test.nim(8Error: unhandled exception: value out of range: -1 notin 0 .. 9223372036854775807 [RangeDefect]
Error: execution of an external program failed: 'D:\Work\Code\gridmonger\test.exe '

@ringabout
Copy link
Member

ringabout commented Feb 5, 2022

Duplicate of #19078

It works on devel, 1.6.2

@johnnovak
Copy link
Contributor Author

It works on devel, 1.6.2

Great to hear, but I can't use 1.6.2 yet due to the FFI bug... I'll just wait for the final 1.6.4.

@ringabout
Copy link
Member

ringabout commented Feb 9, 2022

Here is the release of 1.6.4 https://github.com/nim-lang/Nim/releases/tag/v1.6.4 feel free to reopen the issue if it doesn't work for you.

@johnnovak
Copy link
Contributor Author

Just confirming that the stacktraces work as expected in 1.6.4 with all different GCs.

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

No branches or pull requests

3 participants