z/OS Troubleshooting
S0C5 addressing exception
S0C5 is an addressing exception: the program used an address that is not valid — for example, dereferencing a null or garbage pointer.
What it means
- The CPU could not translate the address the program asked for.
- In COBOL this points at pointer handling: SET ADDRESS, or a linkage-section item used without a proper CALL.
Common causes
- Uninitialized pointer (never SET) used to address data.
- Pointer explicitly set to NULL and then dereferenced.
- LINKAGE SECTION item referenced in a program that was not CALLed with that parameter.
- Overlay corrupted a pointer value.
How to diagnose
- Check register contents in the dump for zero or garbage pointer values.
- Trace where the pointer was last set.
- Confirm the program is CALLed with the expected parameters if LINKAGE is involved.
How to fix it
- Initialize pointers (SET ptr TO NULL) and test before use.
- Guard linkage items: only reference them when the program is properly CALLed.
Example: Null-check pointers before use
IF WS-PTR NOT = NULL
SET ADDRESS OF WS-RECORD TO WS-PTR
... process ...
END-IF.
A one-line NULL test prevents the abend.
Interview tip
- Q: How would you troubleshoot a S0C5 addressing exception in production?
- A: I would inspect the pointer value in the dump, trace its last SET, and confirm whether the program was invoked with the right parameters.
Prevention checklist
- Initialize all pointers.
- Validate CALL interfaces between programs.
