Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
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 () =
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.