| Anonymous | Login | Signup for a new account | 2013-05-19 18:25 CEST | ![]() |
| Main | My View | View Issues | Change Log | Roadmap |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | ||||||
| 0005941 | OCaml | OCaml runtime system | public | 2013-03-11 21:23 | 2013-03-14 17:20 | ||||||
| Reporter | dim | ||||||||||
| Assigned To | dim | ||||||||||
| Priority | normal | Severity | feature | Reproducibility | have not tried | ||||||
| Status | assigned | Resolution | open | ||||||||
| Platform | OS | OS Version | |||||||||
| Product Version | 4.01.0+dev | ||||||||||
| Target Version | Fixed in Version | ||||||||||
| Summary | 0005941: OCaml handler for uncaught exception | ||||||||||
| Description | The attached patch allows the user to register an OCaml function to handle uncaught exceptions. The default handler does the same as the C function except that it calls [Printexc.to_string], which uses user-defined exception printers. The new function is: Printexc.set_uncaught_exception_handler: (exn -> raw_backtrace option -> unit) -> unit The backtrace is [None] when the debugger is active. | ||||||||||
| Tags | No tags attached. | ||||||||||
| Attached Files | |||||||||||
Relationships |
||||||
|
||||||
Notes |
|
|
(0008958) gasche (developer) 2013-03-11 23:49 |
I'm a bit confused by your caml_callback2 invokation: the second parameter is Val_bool(DEBUGGER_IN_USE), while the OCaml type expects an argument of type (raw_backtrace option). Otherwise I'm impressed by the speed at which you made use of the new raw_backtrace type :-) Could you explain what the debugger test is there for? I am not familiar with its interaction with the backtrace code. When developing the raw_backtrace interface, Jacques-Henri Jourdan and I wondered if we should expose whether the backtrace was correctly recorded or not directly in Printexc.get_raw_backtrace, by having it return a `raw_backtrace option` to indicate validity (instead of embedding failure in the type by just returning empty allocated space). We eventually decided to follow what had been done for the rest of the interface, that has explicit no representation of failure to collect traces (we weren't sure we could make sure that the backtrace is valid in all cases), but if you have a different opinion I'd like to know: it's still possible to change the interface in trunk. |
|
(0008960) dim (developer) 2013-03-12 12:15 |
> I'm a bit confused by your caml_callback2 invokation: the second parameter is Val_bool(DEBUGGER_IN_USE), while the OCaml type expects an argument of type (raw_backtrace option). caml_callback2 is applied on Printexc.handle_uncaught_exception, which is a wrapper around the user provided function. > Otherwise I'm impressed by the speed at which you made use of the new raw_backtrace type :-) ;-) > Could you explain what the debugger test is there for? I am not familiar with its interaction with the backtrace code. I'm not 100% sure, but looking at startup.c the debugger interactive loop is called before caml_fatal_uncaught_exception, so that maybe related (the test was already there). Actually I don't think the latter will ever be called when using ocamldebug. > When developing the raw_backtrace interface, Jacques-Henri Jourdan and I wondered if we should expose whether the backtrace was correctly recorded or not directly in Printexc.get_raw_backtrace, by having it return a `raw_backtrace option` to indicate validity (instead of embedding failure in the type by just returning empty allocated space). We eventually decided to follow what had been done for the rest of the interface, that has explicit no representation of failure to collect traces (we weren't sure we could make sure that the backtrace is valid in all cases), but if you have a different opinion I'd like to know: it's still possible to change the interface in trunk. I used an option because of this debugger test, but I should probably follow the same convention as for get_raw_backtrace. I have no strong opinion about whether it should be an option or not, but if get_raw_backtrace cannot be made to return None exactly when the backtrace is invalid I think it is better to just return an empty one. |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2013-03-11 21:23 | dim | New Issue | |
| 2013-03-11 21:23 | dim | Status | new => assigned |
| 2013-03-11 21:23 | dim | Assigned To | => dim |
| 2013-03-11 21:23 | dim | File Added: uncaught-exception-handler.patch | |
| 2013-03-11 21:24 | dim | Relationship added | related to 0005040 |
| 2013-03-11 23:49 | gasche | Note Added: 0008958 | |
| 2013-03-12 12:15 | dim | Note Added: 0008960 | |
| 2013-03-14 11:22 | dim | File Added: uncaught-exception-handler-v2.patch | |
| Copyright © 2000 - 2011 MantisBT Group |