*** Stack guardword corrupted.
This error occurs when the stack area used by an Adaptive Server process is corrupted. Adaptive Server usually shuts itself down after this error to avoid problems that could arise from the stack corruption.
WARNING! If this error occurs and Adaptive Server remains running, shut it down immediately!
At start-up, Adaptive Server allocates one stack area for every configured user connection. These stacks are in contiguous areas of memory, with a guard at the end of each stack. At the end of each stack guard area is a “guardword,” which is a 4-byte structure with a pattern. Adaptive Server periodically checks this pattern to determine whether it has changed. A change indicates that a process has overflowed its stack guard area. When this occurs, Adaptive Server prints the following messages in the error log and shuts down:
kernel: *** Stack overflow detected: <limit>: 0x%lx <sp>: 0x%lx kernel: *** Stack guardword corrupted kernel: *** Stack corrupted, server aborting
In the first message, <limit> is the address of the end of the stack guard area, and <sp> is the current value of the stack pointer.
In addition, Adaptive Server periodically checks the stack pointer to determine whether it is completely outside both the stack and the stack guard area for the process. If it is, Adaptive Server shuts down, even if the stack guardword is not corrupted, and prints the following messages in the error log:
kernel: *** Stack overflow detected: limit: 0x%lx sp: 0x%lx kernel: *** Stack corrupted, server aborting
Stack corruption is usually the result of one process’s stack overflowing its boundaries and writing on top of another process’ stack. In general, an Adaptive Server process writes past the end of its stack area for one of two reasons:
The stack size is too small. The information placed on the stack is valid but its total size exceeds the specified stack size. This is often caused by a single, complex query that requires more than the average amount of stack space.
An incorrectly handled error results in recursive calls that eventually fill the stack, regardless of its size.
If this error occurs because a complex query has run out of stack area, correct the error by using one of the following methods.
Choose solution 1, or choose between solutions 2 and 3 depending on your scenario.
Break up the query into smaller pieces, if possible.
Restart the server. Use the following information to select an appropriate size for the stack size configuration parameter:
The stack size should always be an even increment of 2K (2048 bytes). If a stack size is specified that is not divisible by 2K, Adaptive Server rounds it up to the next 2K increment.
Increase the stack size by no more than 2K at a time. If the stack size is too large, you may be unable to start Adaptive Server.
Increasing the stack size results in Adaptive Server requiring more memory for each configured user connection and device.
Use sp_configure to increase the stack size configuration parameter:
1> sp_configure "stack size", <new_value> 2> go
Where <new_value> is the new stack size.
Once this change is made, shut down and restart Adaptive Server for the change to take effect.
WARNING! If you increase the value of the stack size configuration parameter, you may need to adjust other memory-related parameters. Refer to “Memory Use and Performance” in Performance and Tuning: Basics and “Configuring Memory” in the System Administration Guide: Volume 2.
Restart the Adaptive Server.
Increase the stack size, following the instructions in “Solution 2 – Server remains running after error occurs.”
Increase the stack guard size by 2K. Use sp_configure to increase this parameter:
1> sp_configure "stack guard size", <new_value> 2> go
Once this change is made, restart Adaptive Server to have the change take affect.
Increasing the stack size results in Adaptive Server requiring more memory for each configured user connection and device. Therefore, increasing the stack size without increasing the memory parameter, will result in less total cache space for Adaptive Server and could affect performance.
Refer to “Setting Configuration Parameters” in the System Administration Guide: Volume 1 for information about using the sp_configure procedure and the stack configuration parameters. Also see Reference Manual: Procedures for additional information on sp_configure.