I’m fairly far along in my first Objective CAML application, at the moment ca. 1300 lines. Given a certain file for input, it raises an exception right away, and I was finally motivated to search out the secret OCAMLRUNPARAM incantation (“b”) to get a traceback. And compiled with “-g”.
Sadly, however, that’s no use at all, because each of the reported 9 locations is Unknown, having been inlined by the ocamlc bytecode compiler. I see that in an older version I might have been able to turn that off, with an -inline=0 flag. Is something like that supported in version 4.07?
If memory serves, backtraces should work even in the presence of inlining. Are you sure you are compiling every module with “-g” ? By the way, you can activate exception backtraces by calling “Printexc.record_backtrace true” instead of setting the “OCAMLRUNPARAM” environment variable.
Yes, I witnessed the modules all being compiled with “-g”.
[ … just to double check that, I installed ocaml 4.08 (first ocaml install on this host, MacOS X 10.13), brought over an entirely different program, compiled everything with ocamlc -g. Same thing: two locations in the traceback, neither identified. One of them, identified as “primitive operation at unknown location (inlined)”, was apparently int_of_string. The other, “Called from unknown location (inlined)”. ]
In case this is unclear, I am indeed getting a traceback, or backtrace if you prefer. OCAMLRUNPARAM=“b” yields the same result as Printexc.record_backtrace true - successfully producing a traceback.
The problem is that it looks like this:
Fatal error: exception Invalid_argument(“unknown cv type {”."; “unit”; “U”; “?”; “”}")
Called from unknown location (inlined)
Called from unknown location (inlined)
Called from unknown location (inlined)
Called from unknown location (inlined)
Called from unknown location (inlined)
Called from unknown location (inlined)
Called from unknown location (inlined)
Called from unknown location (inlined)
Called from unknown location (inlined)
This is why I wonder if there is a way to turn off inlining. Is there a way to turn that off?
Indeed, ocamlc does not do inlining (it looks like a bug of the printer to report the calls as inlined).
Given the look of the backtrace, I suspect something like stack corruption or incorrect use of FFIs.
Can you give a bit more context about your code? What does the code that raised the initial exception look like?
Ah, I have to confess that I am an idiot. I use UNIX make to compile all this stuff, configured to use ocaml -c -g for .ml -> .cmo. But the main module is a different ocamlc -o main b.cmo a.cmo main.ml … where I neglected to add -g.
Once I use -g for the main module as well, I get more informative tracebacks. Sorry about this!