With THREAD(*SERIALIZE), or THREAD(*CONCURRENT) where the SERIALIZE keyword is specified
on a procedure specification, if the program runs in the default activation group, the RPG
runtime cannot destroy the mutex used to serialize access to the module or the procedure.
In some cases, after the RPG program has ended, the pointer in the module's static storage
that points to the mutex will be deallocated or overwritten. This situation can cause a
storage leak, because the system's storage associated with the mutex is not freed when
the pointer to the mutex is lost. If the RPG program is called again, it will create a new
mutex.
This situation can arise in the following ways:
- The program is compiled with THREAD(*SERIALIZE) and DFTACTGRP(*YES), and the program
ends with LR on, or it ends abnormally, which causes the program to be deactivated. When
the program is deactivated, its static storage is deallocated.
- The RCLRSC command is used, and a program that uses a mutex to serialize a module or
a procedure ran in the default activation group. A program will run in the default
activation group if it is compiled with DFTACTGRP(*YES) or with ACTGRP(*CALLER), where
the caller is in the default activation group.