This article explains the various reasons an RTS 114 Attempt to access item beyond bounds of memory might be generated.
Problem:
A process can only address memory which it has allocated. When a process tries to address memory it has not allocated, a SIGSEGV or SIGBUS signal is generated by the operating system. The RTS catches these signals and processes any posted signal handlers for the signal. The default RTS signal handler produces the RTS error message:
Execution error : file 'name'
error code: 114, pc=p, call=c, seg=s
114 Attempt to access item beyond bounds of memory (Signal n) -- where n is 10 for SIGSEGV and 11 for SIGBUS.
Resolution:
These signals are usually generated due to either memory corruption or/and invalid pointer usage (in either COBOL or C). Memory corruption involves writing beyond the end of some allocated memory. This memory could be specifically allocated by you using CBL_ALLOC_MEM in COBOL; malloc() in C.
- working-storage items in COBOL
- linkage items in COBOL
- using automatic variables in C
- an uninitialised pointer
- a corrupted pointer
- an invalid pointer - such as one that now points to free memory
Memory corruption and/or invalid pointer usage is almost always due to user error. Occasionally it is due RTS or OS routines but this is very rare.
A 114 error is often intermittent and difficult to reproduce. If you can reproduce the 114 error then you can easily debug it. For more details see the Handling Protection Violation Errors in the Program Development Manual Chapter 5.