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

Loss exception location and backtrace while mix with "c" code #6622

Closed
vicuna opened this issue Oct 21, 2014 · 2 comments
Closed

Loss exception location and backtrace while mix with "c" code #6622

vicuna opened this issue Oct 21, 2014 · 2 comments

Comments

@vicuna
Copy link

vicuna commented Oct 21, 2014

Original bug ID: 6622
Reporter: serp
Assigned to: @mshinwell
Status: closed (set by @mshinwell on 2016-12-08T11:08:47Z)
Resolution: not a bug
Priority: normal
Severity: feature
Version: 4.02.1
Category: runtime system and C interface
Monitored by: @gasche

Bug description

test.ml

exception Test_exn;
value f () = raise Test_exn;
external cfun: unit -> unit = "ml_testf";
value exn_fun p = f ();
Callback.register "ml_exn_fun" exn_fun;
cfun ();

c_stub.c:

#include <caml/mlvalues.h>
#include <caml/callback.h>

void ml_testf(value param) {
value *c = caml_named_value("ml_exn_fun");
caml_callback(*c,Val_int(1));
}

Compile it to byte with -custom option
./test.byte
Fatal error: exception Run.Test_exn
Raised by primitive operation at file "run.ml", line 6, characters 0-7

======
ocaml-4.01 output

Fatal error: exception Run.Test_exn
Raised at file "run.ml", line 2, characters 19-27
Called from file "run.ml", line 6, characters 0-7

@vicuna
Copy link
Author

vicuna commented Dec 8, 2016

Comment author: @mshinwell

This appears to happen because a toplevel module initialiser is raising an exception that is caught by the default handler inside caml_startup_code. #953 provides a solution to this problem if it is desired to catch such exceptions.

@vicuna
Copy link
Author

vicuna commented Dec 8, 2016

Comment author: @mshinwell

(And you would need to use -output-obj rather than -custom.)

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

2 participants