Highlighted
Absent Member.
Absent Member.
1544 views

Stack Overflow issue: is there a limit?

We have a COBOL program that was migrated from Bull mainframe syntax to Visual COBOL. It took some work to get it to run, because not all of the code is "optimal". It's over 17,000 lines, and calls other assemblies. We had to go away from Perform Thru using Sections in some parts, back to using GOTO to get it to run using Visual COBOL.

One of the other changes we made was to increase the stack size, using a compiler directive. Initially, we went to 200 megs (200 X 1024 X 1024) after receiving a stack overflow exception using the Visual COBOL default settings. After a couple of weekly runs, we experienced a Stack Overflow exception again. Since it was in production, and we needed the run for that night, the stack was increased to 300 megs. This happened a couple of times, until this last week it was increased to 500 megs. This has been the solution to a stack overflow without rewriting the program, which would be a daunting task. The compiler directive is this:       $SET ILSTACKSIZE(524288000)

I realize that rewriting the program is the way to go. But for the time being, is there an upper limit to how big I can increase the stack size to? Is there an upper limit when this will no longer be an option?

Also, is there a way to monitor the stack size of a program, during execution? That way we might have an idea of what might be causing it, and when the stack size is getting too large and will need to be increased soon.

0 Likes
1 Reply
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Stack Overflow issue: is there a limit?

Hi Jay,

There can be a problem with this type of program where there may be overlapping perform ranges or GO TO statements that jump out of one section and into a different one, when compiling for managed code. This is because behind the scenes the compiler is generating these sections and paragraphs as OO methods and if there is no logical place to split these sections into methods then it will include the entire range within one large method which can cause this type of stack overflow you are seeing.

We would recommend that you try compiling with the directive PERFORMTYPE”OSVS” to see if you get a better behavior. If you still get a stack overflow then you can use the directives RESTRICT-GOTO and ILSHOWPERFORMOVERLAP to help you find the problem areas in your program. If the program is large like you say then there might be quite a few offending lines of code. I have seen cases where a single GO TO out of a performed section to the exit paragraph of a different section could cause a stack overflow condition.

If you would like help diagnosing this problem then please open up a support incident with customer care and attach this program and copybooks (or .lst file compiled with RAWLIST) to the incident so that we can take a look at it.

Thanks..

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.