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

wrong backtrace printed when mixing modules with and without debug info #5074

Closed
vicuna opened this issue Jun 15, 2010 · 2 comments
Closed

Comments

@vicuna
Copy link

vicuna commented Jun 15, 2010

Original bug ID: 5074
Reporter: @ygrek
Status: resolved (set by @xavierleroy on 2015-11-28T11:13:39Z)
Resolution: suspended
Priority: normal
Severity: minor
Version: 3.11.2
Category: ~DO NOT USE (was: OCaml general)
Monitored by: mehdi @diml Camarade_Tux @hcarty @Chris00 @alainfrisch

Bug description

$ cat a.ml
exception Error
let fail () = raise Error

$ cat b.ml
let f () =
ignore (A.fail ())

let () =
(try failwith "oops" with _ -> ());
f ()

$ cat run
ocamlc -c a.ml -o a.cmo
ocamlc -c -g b.ml -o b.cmo
ocamlc -g a.cmo b.cmo -o b.byte
ocamlopt -c a.ml -o a.cmx
ocamlopt -c -g b.ml -o b.cmx
ocamlopt -g a.cmx b.cmx -o b.native
OCAMLRUNPARAM=b ./b.byte
OCAMLRUNPARAM=b ./b.native

$ ./run
Fatal error: exception A.Error
Called from file "b.ml", line 2, characters 9-20
Called from file "b.ml", line 6, characters 2-6
Fatal error: exception A.Error
Raised at file "pervasives.ml", line 22, characters 22-33
Called from file "b.ml", line 5, characters 7-22

The backtrace for b.native is absolutely wrong.
Note that a.ml is compiled without -g option.

Additional information

Funny thing - if module A raises predefined exception instead of newly defined Error - everything is ok.
Minor note - no "Raised at" printed for b.byte

@vicuna
Copy link
Author

vicuna commented Jul 31, 2014

Comment author: @damiendoligez

Some progress has been made on this issue: now the native code says
Fatal error: exception A.Error
Raised by primitive operation at file "b.ml", line 2, characters 9-20
which is basically correct, considering that the "fail" function is probably inlined.

On the other hand, the bytecode result hasn't changed, it's still missing the "Raised by" line.

@vicuna
Copy link
Author

vicuna commented Nov 28, 2015

Comment author: @xavierleroy

Yes, the inlining of A.fail produces a decent backtrace. The original problem is still there if a.ml is compiled with ocamlopt -inline 0, though.

I don't see any reasonable fix here. If one compiles with ocamlopt and without -g, it's to get the absolutely fastest implementation of exception raising, which doesn't reset the "last exception raised" global variable. Resetting that variable would defeat the purpose of getting the absolutely fastest implementation of exception raising.

More generally, mixing object files compiled with -g and without -g is not a scenario that I want us to spend implementation efforts on. Suspending this PR.

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