z/TPF - Group home

APAR PJ43067 – ECB Stack Validation Mode

  

This SPE APAR delivers a new system trace option called ECB stack validation mode.

 

With this support, you can find and debug certain coding errors, such as writing beyond the end of an allocated ECB stack frame or beyond the bounds of an ECB stack. You can turn on or turn off ECB stack validation mode by using the STACKVAL parameter on the ZSTRC command.

 

When ECB stack validation mode is on, the following conditions occur:

  • At each C function entry, C function exit, ENTxC macro, and BACKC macro, the application stack is traversed, and each back chain pointer is inspected. If the back chain pointer for an application stack frame does not point within the bounds of the stack area of an ECB, the z/TPF system issues the 064009 system error, and the ECB exits.
  • A maximum of 100 application stack frames are inspected to prevent infinite loops.

 

The following examples are coding issues that you might find by using the ECB stack validation mode:

  • The FRAMESIZE parameter specified on the PRLGC macro for a function is calculated incorrectly.  For example, assume a DSECT is used as a work area in a function and the length of that DSECT is hardcoded for the FRAMESIZE parameter. With this method, any time the DSECT is updated to add new fields, the FRAMESIZE parameter must be updated. If the FRAMESIZE is not updated, the code might corrupt other portions of the stack.
  • Allocate a buffer that data is stored in and call a function like sprintf() to format the buffer for output.  If one of the parameters is a string (%s) and the input buffer was not initialized to NULL previously, the sprintf() function might process more data than you want and corrupt other portions of the stack.

 

Note: Use ECB stack validation mode with caution in a production system because it degrades CPU performance.  The recommended use for this system trace would be in a test system environment.

 

For more information about APAR PJ43067, see the APEDIT.