Stack guardword corrupted

Message text

*** Stack guardword corrupted.

Explanation

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:

Action

If this error occurs because a complex query has run out of stack area, correct the error by using one of the following methods.

NoteChoose solution 1, or choose between solutions 2 and 3 depending on your scenario.


Solution 1

Break up the query into smaller pieces, if possible.


Solution 2 – Server remains running after error occurs

Restart the server. Use the following information to select an appropriate size for the stack size configuration parameter:

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.


Solution 3 – Server shuts down after error occurs

  1. Restart the Adaptive Server.

  2. Increase the stack size, following the instructions in “Solution 2 – Server remains running after error occurs.”

  3. Increase the stack guard size by 2K. Use sp_configure to increase this parameter:

    1> sp_configure "stack guard size", <new_value>
    2> go
    
  4. Once this change is made, restart Adaptive Server to have the change take affect.

Additional information

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.