Saturday, November 17, 2012

CICS Storage Violations


CICS Storage violations can seem to be one of the most difficult problems to deal with when debugging. Storage Violations can in the worst cases bring down CICS and can sometimes go undetected by CICS which could lead to problems in the future. Storage violations involving overwriting CICS control blocks or CICS storage will in most cases lead to CICS ‘falling over’. Storage violations of user storage areas can sometimes go undetected and may not cause a CICS failure.
By understanding how CICS detects storage violations, you can make the task of debugging a storage violation easier.
When you request an area of storage in CICS, such as for the program’s commarea, CICS will add 16 bytes of storage to the area of storage. It adds 8 bytes at the start and 8 bytes at the end. CICS will then put a value in each of these areas. If the value changes then CICS will detect a storage violation! However, CICS will not necessarily detect the storage violation when it happens. This is because CICS will only check for a violation when the area of storage is freed up. So the storage violation could occur at the start of your program but not actually be detected until later, for example when the program terminates or calls another program.
The most common reasons for storage violations are programming errors. Common reasons are different length DFHCOMMAREAs when your program calls or is invoked by another program, or subscript errors causing data to be stored beyond the end of the storage area.
It is also possible that another program has overwritten your storage, your program may detect that it’s storage has been overwritten by the other program. If you suspect that it is not your program that is at fault, try doing a CEMT New Copy of your program.
As CICS has evolved new methods of protecting storage have been added to CICS (From version 3.3 of CICS it has been possible to switch storage protection on in a CICS region) , however many sites still do not take advantage of them this may be because some older software may require that the storage protection options be switched off.
 If you switch on storage protection in a CICS region, then you may find that you get a lot more storage violations in existing programs, this could be because the storage violations went undetected previously.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.