Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005855OCamlruntime system and C interfacepublic2012-12-14 17:452016-12-08 10:59
Assigned Toshinwell 
PlatformOSOS Version
Product Version4.00.1 
Target VersionFixed in Version 
Summary0005855: Compiling in debug mode should turn on caml_record_backtrace by default
DescriptionAt the moment, the OCAMLRUNPARAM=b and compiling in debug mode with '-g' are orthogonal. Is there any reason that programs compiled with '-g' shouldn't have 'b' enabled by default?
Steps To ReproduceCompile a program with -g and set OCAMLRUNPARAM="", and see the lack of backtraces.
TagsNo tags attached.
Attached Files

- Relationships
related to 0006728acknowledged Enable -g and OCAMLRUNPARAM=b by default 

-  Notes
ygrek (reporter)
2012-12-14 17:49

-g adds debug information which can be useful without wasting time recording backtraces of all exceptions, e.g. for sampling profiling.
gasche (developer)
2013-02-10 09:35

I came to submit the exact same feature wish, which has been suggested to me by a programmer unfamiliar with OCaml, which was surprised `-g` did not activate stack printing by default. Given the documentation of the `-g` flag, this is a reasonable expectation:

  -g Record debugging information for exception backtrace

As ygrek says, there are other uses of -g that don't need or want the corresponding overhead, but I think we should make the common case the simpler to use, and let expert with other use cases use `OCAMLRUNPARAM="b=0"`.
chambart (developer)
2013-02-11 10:52

Something like that would improve a lot average bug report when classical users are not necessarily familiar with
OCaml and you can't expect user to come back providing more informations. This kind of situation is common on
linux distribution bug trackers.
gasche (developer)
2013-02-11 11:39
edited on: 2013-02-11 14:04

(Eating a previous suggestion about treating unhandled exceptions differently from the others. Indeed, with dynamically filtering exception handlers, it's impossible to know which exceptions will be handled by the stack of existing handlers without executing them, at which point the stack is already discarded unless b=1.)

doligez (administrator)
2013-06-19 20:40

What is the best way to implement this?
ygrek (reporter)
2013-06-20 04:17

I am against this behavior change. When this gets implemented suddenly all -g enabled libraries experience a performance hit. Running with OCAMLRUNPARAM=b=0 is not an option, how do you expect this to happen - wrap every program start in shell script? OCaml is different from other languages wrt exceptions, so it is not unreasonable to expect another behavior of -g. The arguments like "same feature wish, which has been suggested to me by a programmer unfamiliar with OCaml" are not valid, programmers unfamiliar with OCaml will find many strange things to complain about - polymorphic variants, labeled arguments (just had to deal with this one today), etc, etc - it is not a valid reason to change anything. OCaml is different, starting with syntax - because it has some objective reasons behind this decisions. The cost of printing backtrace is different - that's why it is not enabled by default. Why should we adopt the practice from other systems where it has totally different performance cost? If this is getting to be implemented I am strongly for another option, -gg or whatever, not changing the semantics of current option.
jacques-henri.jourdan (manager)
2013-06-20 07:58

One solution could be to activate it only when linking the final executable with -g...
doligez (administrator)
2013-12-16 13:44

I'd rather add a new option -gg than introduce a subtle difference in -g used for compiling or linking.
shinwell (developer)
2016-12-08 10:59

Compile-time flags for debugging-related options will need revising in the light of the GDB work that will hopefully be merged in time for 4.05. We could consider having this kind of backtrace control as one of those options, perhaps.

- Issue History
Date Modified Username Field Change
2012-12-14 17:45 thelema New Issue
2012-12-14 17:49 ygrek Note Added: 0008611
2013-02-10 09:35 gasche Note Added: 0008835
2013-02-11 10:52 chambart Note Added: 0008836
2013-02-11 11:39 gasche Note Added: 0008837
2013-02-11 14:04 gasche Note Edited: 0008837 View Revisions
2013-06-19 20:40 doligez Note Added: 0009577
2013-06-19 20:40 doligez Status new => confirmed
2013-06-20 04:17 ygrek Note Added: 0009582
2013-06-20 07:58 jacques-henri.jourdan Note Added: 0009583
2013-12-16 13:44 doligez Note Added: 0010719
2014-12-19 15:19 whitequark Relationship added child of 0006728
2014-12-19 15:20 whitequark Relationship replaced related to 0006728
2016-12-08 10:59 shinwell Note Added: 0016838
2016-12-08 10:59 shinwell Assigned To => shinwell
2016-12-08 10:59 shinwell Status confirmed => assigned
2017-02-23 16:43 doligez Category OCaml runtime system => runtime system
2017-03-03 17:45 doligez Category runtime system => runtime system and C interface

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker