Lwt program; stack overflows and SIGSEGVs; heap check assetion fail in freelists.c with debug runtime

If you are interested in backtraces of exceptions (which is a smaller problem than that of restoring the original call graph) then there’s a modern way of doing so: Lwt.reraise. Check the doc for full details but TL;DR: replace your old catch catch all case | exc -> raise exc with the new | exc -> Lwt.reraise exc.

Lwt.reraise is bound to the OCaml’s internal %reraise which does some magic when maintaining the backtraces of exceptions. It essentially allows you to have the same behaviour as omitting a catch-all case when writing a vanilla try-with.

3 Likes