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

invoking nim procedures from C do not trap unhandled exceptions. #18215

Open
planetis-m opened this issue Jun 8, 2021 · 0 comments
Open

invoking nim procedures from C do not trap unhandled exceptions. #18215

planetis-m opened this issue Jun 8, 2021 · 0 comments

Comments

@planetis-m
Copy link
Contributor

The following is the modified example from https://nim-lang.github.io/Nim/backends.html#interfacing-backend-code-calling-nim test with and without --gc:arc to see the difference.

Example

fib.nim

proc testOneInput: cint {.exportc.} =
  if true:
    raise newException(ValueError, "my my my")

proc customMutator(): int {.exportc.} =
  try:
    discard
  except:
    echo "customMutator"
    quit(1)

maths.c

#include "fib.h"
#include <stdio.h>

int main(void)
{
  NimMain();
  testOneInput();
  // the following should not be called
  customMutator();
  return 0;
}

Current Output

with --gc:arc

customMutator

Expected Output

without

Error: unhandled exception: my my my [ValueError]

Possible Solution

Something to do with nimTestErrorFlag() not being called.

$ nim -v
1.5.1
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