Reducing the risk of segfault due to stack overflow #5485
Original bug ID: 5485
We just had a segfault due a stack overflow. It occurred during the compare_val function while doing a Hashtbl.find_all on an excessively deep bucket. It took me close to two days to identify the source of the problem and to fix it in our unfriendly environment (Hadoop map/reduce). Having a stack trace in this case would have saved about a day of debugging.
Here is a simple repro case:
----- overflow.ml -----
let () =
The text was updated successfully, but these errors were encountered:
Comment author: @xavierleroy
It might be possible to raise a Stack_overflow in this case (if there is not enough stack space available before calling into a C function), either as suggested in #5064, or (even more cheaply) by putting the "stack touch" sequence in caml_c_call and caml_call_gc. Generating a meaningful stack backtrace is much more difficult, though.