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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling sysFatal gracefully #128

Open
adigitoleo opened this issue Jan 15, 2022 · 3 comments
Open

Handling sysFatal gracefully #128

adigitoleo opened this issue Jan 15, 2022 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@adigitoleo
Copy link

Unhandled sysFatal from top level scope can crash the repl:

%zsh> inim
馃憫 INim 0.6.1
Nim Compiler Version 1.6.0 [Linux: amd64] at /usr/bin/nim
nim> var s = newSeq[int](5)
nim> s[5] = 42
fatal.nim(53)            sysFatal
Error: unhandled exception: value out of range: -1 notin 0 .. 9223372036854775807 [RangeDefect]

Other unhandled sysFatal don't show the error message:

%zsh> inim
馃憫 INim 0.6.1
Nim Compiler Version 1.6.0 [Linux: amd64] at /usr/bin/nim
nim> proc oof() =
....   var s = newSeq[int](5)
....   s[5] = 42
....
nim> oof()
/usr/lib/nim/lib/system/fatal.nim(53) sysFatal
@0atman
Copy link
Collaborator

0atman commented Mar 30, 2022

confirmed, these should not crash the repl, ideally. Perhaps they should be removed from execution so that further commands can continue?

@0atman 0atman added the help wanted Extra attention is needed label Mar 30, 2022
@adigitoleo
Copy link
Author

Looks like the crash isn't happening any more with nim 1.6.6, the message is still missing in the second case however.

@adigitoleo
Copy link
Author

Crash is back, either I was talking nonsense before or it is reintroduced. My naive idea for this was to somehow catch sysFatal during the internal compile cycle (although I understand that it's more like a panic than an exception), but that requires a better understanding of fatal.nim than I have:
https://github.com/nim-lang/Nim/blob/devel/lib/system/fatal.nim

In particular, Nim is not always simply raiseing something, there's a few platform/compiler-flag specific behaviours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants