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

CoreDump in C/Caml interface with caml_callback_exn #4343

Closed
vicuna opened this issue Jul 16, 2007 · 1 comment
Closed

CoreDump in C/Caml interface with caml_callback_exn #4343

vicuna opened this issue Jul 16, 2007 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Jul 16, 2007

Original bug ID: 4343
Reporter: daweil
Status: closed (set by @xavierleroy on 2007-10-25T09:02:08Z)
Resolution: won't fix
Priority: normal
Severity: crash
Version: 3.10.0
Category: runtime system and C interface

Bug description

Why do this program crash ?
This small program call a CAML function which does nothing but do "raise Exit" from C.
Before the call to CAMLreturn, a call to another CAML function which compact the GC is triggered.
The program crash if the function caml_callback_exn is raised instead of caml_callback.
The correction I found was to write "caml_local_roots = caml_frame" before calling the second CAML function.
Is a bug in the CAML compiler or a bug in the documentation of the C/CAML writing rules ?

Daniel Weil

Additional information

To reproduce the bug, unzip the file src.zip
Type "make", the "make run".
The makefile is for Windows, but I suspect the bug to be reproductible on other OS also.

File attachments

@vicuna
Copy link
Author

vicuna commented Oct 25, 2007

Comment author: @xavierleroy

The value returned by caml_callbackN_exn should not be registered as a GC root, as it is not a well-formed value in the case where an exception is returned.

In other terms, consider:

x = caml_callbackN_exn(..., ...);
if (Is_exception_result(x)) { exn = Extract_exception(r); } else { res = x };

exn and res are well-formed values and can be registered as roots, but x is not.

It could be argued that the caml_callback_exn API should be rewritten to avoid this problem, but I'm afraid we're stuck with it.

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

1 participant