Skip to content

Base implementation of catching exceptions made in C stubs#433

Open
SturdyPose wants to merge 15 commits intomirage:mainfrom
SturdyPose:sturdypose/add-stack-tracing-for-nullptrs
Open

Base implementation of catching exceptions made in C stubs#433
SturdyPose wants to merge 15 commits intomirage:mainfrom
SturdyPose:sturdypose/add-stack-tracing-for-nullptrs

Conversation

@SturdyPose
Copy link

@SturdyPose SturdyPose commented Feb 20, 2026

The goal of this PR is to fix #430

  • Add base implementation for catching segmentation faults with try catch block
  • Implementation for windows stacktraces
  • Implementation for linux stacktraces
  • Credit author for collecting windows stack trace in the comments - https://smhk.net/note/2025/03/c-stack-trace-in-windows/
  • Update stubs.expected file
  • Export different exception structs like SegFault
  • Make working JS backend build

Open to any feedback. :)

Copy link
Collaborator

@MisterDA MisterDA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a bit of mixed indentation in the C file, please reformat the Windows code to be consistent with the rest.

@SturdyPose
Copy link
Author

Applied clang-format on source

@SturdyPose
Copy link
Author

Seems like windows containers are broken because they don't have npm and I'm unsure why mac is not catching the exception... 🤔

@SturdyPose
Copy link
Author

Yeah, I'll need to rethink the implementation of reporting it back to ocaml -> might not be possible at all. There can be stack corruption and that would lead to undeterministic results. Do you think that reporting it to stderr would be good enough?

@MisterDA
Copy link
Collaborator

For the unix part maybe you need a signal handler on the ocaml side instead?

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

Successfully merging this pull request may close these issues.

Alcotest silently fails when aborted from C stub

2 participants