A program stops with fatal error:
Error 115 Unexpected signal (Signal 4)
on SUSE or Red Hat Linux running on s390 (i.e. z/390 or IBM 390) hardware, when the program is compiled to executable or .gnt or .so.
Modify the COBOL source code so invalid data is not used, including making sure data items are initialized before being used, or as an alternative, compile with the compiler directive SIGN-FIXUP
Consider this example program:
000001 program-id. cd1. 000002 environment division. 000003 configuration section. 000004 data division. 000005 000006 working-storage section. 000007 01 WS-CAS-ID PIC S9(8) COMP-3. 000008 01 WSH-HOLD. 000009 05 WSH-PREV-CASE-ID PIC S9(8) COMP-3. 000010 000011 procedure division. 000012 move 1 to WS-CAS-ID 000013 IF WS-CAS-ID = WSH-PREV-CASE-ID 000014 display "is equal" 000015 ELSE 000016 display "not equal" 000017 END-IF 000018 . 000019 000020 goback 000021 .
When compiled to .int on any platform (Windows, AIX, Solaris, Linux) then at runtime the program stops with this error:
163 Illegal character in numeric field
because WSH-PREV-CASE-ID is not initialized before being used, and so contains spaces (or contains the value specified in the DEFAULTBYTE compiler directive). Spaces are illegal characters in COMP-3 representation.
The best solution is to modify the code so invalid data is not used, including making sure data items are initialized before being used. However, the code may originally have come from the IBM mainframe, which handles uninitialized or invalid data differently.
When compiled to executable or .gnt or .so, on all platforms (Windows, AIX, Solaris, Linux) except Linux on s390 hardware, at runtime the program displays:
But on s390 hardware, it stops with Error 115 Unexpected signal (Signal 4). Signal 4 means "illegal instruction", that is, the machine code in the running executable is illegal.
s390 processors provide machine code instructions specifically for handing COBOL comp-3 and display data, and the Micro Focus Native Code Generator generates machine code using these instructions where possible and where they are faster than the alternatives. These machine instructions raise a signal if the data is not valid. This behavior is compliant with ANSI, MF, and IBM documentation. If numeric data is invalid, and you do not use numeric checking, anything can happen.
The compiler directive SIGN-FIXUP provides compatibility with the way IBM Mainframe COBOL handles invalid data. When compiled with SIGN-FIXUP to executable or .gnt or .so, on all platforms including s390, the program will display:
This will solve the error 115 Unexpected signal.