Kbase P112690: 4GL program crashes, using SET-POINTER-VALUE() and SET-SIZE().
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/16/2008 |
|
Status: Verified
FACT(s) (Environment):
All Supported Operating Systems
Progress 9.x
OpenEdge 10.x
SYMPTOM(s):
4GL program crashes
Program uses MEMPTR variables
Program performs SET-POINTER-VALUE() on a MEMPTR variable.
Program performs SET-SIZE() = 0 on the same MEMPTR variable.
Program does not crash immediately after the SET-SIZE() statement
CAUSE:
The statement SET-SIZE() = 0 must be used against the same MEMPTR variable used to allocate the memory.
Failure to do so may result in the same area of memory being freed twice, which corrupts the memory management in the underlying operating system, and will eventually lead to a session crash.
An example of incorrect usage is the following:
/* Incorrect code. */
SET-SIZE(firstVar) = 10. /* Allocate memory */
SET-POINTER-VALUE(secondVar) = GET-POINTER-VALUE(firstVar).
SET-SIZE(secondVar) = 0. /* Deallocate memory */
FIX:
Fix your code so that SET-SIZE() = 0 is executed against the same MEMPTR variable used to allocate the memory. For example:
/* Correct code. */
SET-SIZE(firstVar) = 10. /* Allocate memory */
SET-POINTER-VALUE(secondVar) = GET-POINTER-VALUE(firstVar).
SET-SIZE(firstVar) = 0. /* Deallocate memory */
secondVar = ?. /* Null-out secondVar, as we don't want to
re-used its value by mistake. */