Memory Access Violations

If your program tries to access a portion of memory that is protected by the operating system, ACUCOBOL-GT generates a memory access violation message and shuts down.

The most common cause of this violation is indexing beyond the legal range of a table. Often this sort of error is difficult to detect, because it can be data-dependent, as shown in this example:

PERFORM UNTIL IDX > NO-OF-EMPLOYEES  
   DISPLAY "EMPLOYEE NAME:   ", EMP-TABLE(IDX)
   ADD 1 TO IDX
END PERFORM.

If NO-OF-EMPLOYEES ever exceeds the size of EMP-TABLE, or if IDX is ever set to zero, you could get a memory access violation when the program is run.

To uncover this type of memory access violation, use the -Za compile-time option while you are debugging your program. When you run a program that has been compiled with -Za, ACUCOBOL-GT prints a subscript out of bounds error message, detailing the legal range of indexes for any table-indexing error that it encounters. (Note that the subscript out of bounds error appears when you run the program, not when you compile it.) You can then correct the program as necessary.

A memory access violation can also occur if there is a bug in any C routine linked into the runtime. Because of the nature of C, the violation can occur long after the called C function executes.