MCH3601: Pointer not set for location referenced
MCH3601 (Pointer not set for location referenced) means a program on IBM i tried to use storage through a pointer that holds no address. The most common reason is a parameter the caller didn't pass.
Other names for this code
Also written as MCH3601 error, MCH3601 pointer not set, pointer not set for location referenced, MCH3601 RPG, MCH3601 CL program, MSGID MCH3601.
What it means
MCH messages come from the machine interface, the layer below the operating system that runs every program's instructions. MCH3601 is the one the machine sends when an instruction needs an address and the pointer it was given is empty. The program asked for data at a location, and there was no location.
Parameters are the usual way this happens. On IBM i, parameters are passed by reference, so each one is really a pointer to the caller's storage. If the caller passes two parameters and the called program declares three, the third has no pointer behind it. Nothing goes wrong until the program touches that third parameter. Then MCH3601 arrives, often several statements after the program started.
The message is an escape message sent to the program that ran the failing instruction. If that program doesn't handle it, the language takes over. An RPG program reports status 00222 (pointer or parameter error) and, with no handler, shows inquiry RNQ0222. A CL program gets an inquiry such as CPA0701. Other programs end with function check CPF9999.
Common causes
- A program was called with fewer parameters than it declares. Typical cases are a
CALLtyped on a command line without thePARMvalues, a menu option that passes nothing, or a caller that was never updated after a parameter was added. - An optional parameter (RPG
OPTIONS(*NOPASS)or*OMIT) was used without first checking that it was passed. Check%PARMSor test the address against*NULLfirst. - A field based on a pointer (RPG
BASED, COBOLSET ADDRESS OF, a C pointer) was used before the pointer was set, or after the storage it pointed to was freed. - An ILE COBOL program referred to a record or field of a file that was closed, or that never opened because the OPEN failed and nobody checked the file status.
- An SQL stored procedure was started with the CL
CALLcommand instead of SQLCALL. IBM notes this almost always ends in MCH3601. An unqualified SQL call that misses the procedure in the SQL path and finds a plain program of the same name can do the same.
How to find the problem
- Run
DSPJOBLOG, put the cursor on MCH3601 and press F1. Then press F9 for the message details. The to program, module, procedure and statement show where the empty pointer was used. - Look at that statement in the source. If it uses a parameter, compare the caller's parameter list with the called program's entry list (
*ENTRY PLIST, the procedure interface, the CLPGM PARM(...)or the COBOLPROCEDURE DIVISION USING). - Check how the program was started. A job log that shows a
CALLwith noPARMkeyword, or a menu that runs the program directly, points straight at a missing parameter. - If no parameter is involved, find the pointer the statement uses and trace where it is set. Debug with
STRDBGand stop on the statement before it to see whether the pointer is null.
How to fix it
- Make the caller pass every parameter the program needs, with matching types and lengths. For RPG callers, a prototype checked at compile time stops the mismatch from coming back.
- Guard optional parameters. In RPG, test
%PARMSbefore using a*NOPASSparameter and copy it to a local field with a default. In CL, useMONMSG MCH3601on the first statement that touches an optional parameter. - Set based pointers before use, and clear them after the storage is freed, so a later mistake fails on a check you wrote instead of on MCH3601.
- In COBOL, check the file status after every OPEN and stop before any read or write if it failed.
- Call SQL procedures through SQL, either with a qualified name or with the SQL path set so the right procedure is found.
What it looks like
Pointer not set for location referenced.
IBM documentation
IBM Display Message Descriptions (DSPMSGD). Use the documentation for your installed release.
This link opens the relevant IBM reference library or lookup instructions. Match the complete code and your installed product release; it is not a code-specific review.
Read the installed message description:
DSPMSGD MSGID(MCH3601) MSGF(QSYS/QCPFMSG)
Also inspect the full job log and second-level message text, including substitution values.
Related codes
Questions
Why does my CL program fail with MCH3601 when I call it from the command line?
The CL program declares parameters and the CALL didn't pass them. The program runs until it touches the first missing parameter. Call it with PARM values, or monitor for MCH3601 if the parameter is meant to be optional.
How is MCH3601 related to RNQ0222?
MCH3601 is the machine's message. RNQ0222 is how ILE RPG reports it when the program has no error handling. RPG maps it to status 00222, pointer or parameter error.