Stack Overflow Error in native Cobol



During runtime you get Stack Overflow errors when Cobol DLLs are called. As the levels of inheritance grow up to a specific level everything runs fine, but when you move a step down in the inheritance level you get a stack overflow error.


The usual cause of this kind of exception is that there is not enough stack space, and this is one of those cases. 

The default stack size for a Windows executable is only 1Mb. To increase the stack size there are a couple of options here ...

1) Build the top-level code to an exe, and include a larger stack size

e.g. set link=/stack:2000000
cbllink cobclient.cbl

2) Use editbin (in a VS command prompt) on the MF run trigger, to increase its stack size

e.g. editbin /stack:2000000 run.exe

The issue will not appear with INT code since in that case local storage is dynamically allocated from the Windows heap rather than from the system stack.

Comment List