COBOL Manual for TNS and TNS/R Programs

Run-Time Diagnostic Messages
HP COBOL Manual for TNS and TNS/R Programs522555-006
48-9
Stack Overflow
Stack Overflow
Stack overflow means that the control and data stack has overflowed.
TNS Programs
In a TNS program, the most common cause is a shortage of data space in the user
data area. To determine whether this is the case, you need a data map of the run unit.
For a TNS program, you can use the BIND command
LIST LOC FROM fname
to create a data map for file fname. Examine the data block map to find the last
address less than 100000 octal. If this address is greater than 70000 octal, you might
not have enough room to execute. There are several ways to fix the problem:
Move one or more large data items (such as large tables) from the Working-
Storage Section to the Extended-Storage Section.
Reduce arrays to fewer elements.
Eliminate unused data items (a cross-reference listing might help you find them).
Make seldom-called programs initial programs (specify INITIAL in the PROGRAM-
ID paragraph).
If there appears to be enough room, but your program still terminates abnormally, your
run unit might have a loop in it. To determine the cause, compile the program with the
SYMBOLS and INSPECT directives, and run it in debug mode (with the RUND
command) by using the selected debugger to examine the contents of the variables
when the program terminates abnormally.
One likely cause of abnormal termination is a PERFORM loop that lacks proper
termination. If, during the execution of a procedure, control passes out of the
procedure and then control passes back through the PERFORM statement again, the
stack space dedicated to maintenance of the procedure is never freed.
Native Programs
For native programs, the most likely cause of stack overflow is calling one or more
initial programs that have large amounts of data declared in the Working-Storage
Section or Extended-Storage Section. Data in initial programs is allocated on the stack,
and the area of memory reserved for the stack is much smaller than the area reserved
for static data. There are several ways to fix this problem:
Move one or more large data items (such as large tables) from the initial program
to a noninitial program that calls it, and pass the data items as parameters.
Reduce arrays to fewer elements.
Eliminate unused data items.