> When I compile the following program as byte code I see a stack overflow
> (expected). When using ocamlopt it seems that the program dies and I do
> not see the expected overflow exception?
> [under Windows]
Right. Given your e-mail address, you might actually understand
better than I why it is so. Let me explain:
The machine code generated by ocamlopt does not test explicitly for
stack overflows, relying instead on the operating system to detect and
report them. However, handling of stack overflow conditions varies
greatly between processors and operating systems. Currently:
- Under Linux/IA32 and Linux/AMD64, stack overflows are properly
turned into a Stack_overflow Caml exception. Similar handling is
in the CVS for MacOSX/PPC, and MacOSX/Intel might be feasible soon.
- Other Unix-like operating systems just report stack overflows
as a "segmentation violation" or "bus error" fatal signal.
- Windows, as you noticed, behaves strangely. Stack overflows are turned
into Win32 system exceptions, but apparently the structured
exception handling of Win32 just fails to handle them and silently
exits the program. That might be because the stack frames generated
by ocamlopt are nothing like what Win32 expects.
If you happen to know how to do better under Windows, you're most
welcome to let me know.
- Xavier Leroy