# Stack overflow reported as segfault (?)

**URL:** <https://discuss.ocaml.org/t/stack-overflow-reported-as-segfault/8646>\
**Category:** Learning\
**Created:** [October 18, 2021, 11:48am UTC](https://discuss.ocaml.org/t/stack-overflow-reported-as-segfault/8646 "2021-10-18T11:48:29Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![xavierleroy](https://avatars.discourse-cdn.com/v4/letter/x/a9adbd/32.png) [@xavierleroy](https://discuss.ocaml.org/u/xavierleroy)\
**Post date:** [October 19, 2021, 8:21am UTC](https://discuss.ocaml.org/t/stack-overflow-reported-as-segfault/8646/8 "2021-10-19T08:21:24Z")

</div>

The long-term goal is that stack overflows from OCaml code are properly reported as `Stack_overflow` exceptions, and stack overflows from C code are (1) avoided if at all possible in the OCaml run-time system, and (2) reported as SEGV signals otherwise. But catching stack overflows is tricky, both in Unix-like systems and under Windows, so the current implementation in OCaml is a best effort that is occasionally buggy.

So, with native code compilation, never rely on stack overflows being turned into exceptions. Just treat the `Stack_overflow` as a debugging aid.

---

_[View the full topic](https://discuss.ocaml.org/t/stack-overflow-reported-as-segfault/8646)._
