Compilation of file "create-sort-crash-report-this.cob" with cobc aborts without recovering from missing file assignment error. This is from SVN Rev 5546:
cobc: ../../cobc/typeck.c:13418: invalid cast from 'NULL' type None to type FILE
cobc says: Please report this!
cobc -x create-sort-crash-report-this.cob
create-sort-crash-report-this.cob:24: error: 'SORT-DATEI' is not defined
22 | 05 DATEN-INHALT PIC X(50).
23 |
24 > SD SORT-DATEI.
25 | 01 SORT-SATZ.
26 | 05 SORT-SCHLUESSEL PIC X(10).
create-sort-crash-report-this.cob:24: error: 'SORT-DATEI' is not a file name
cobc: ../../cobc/typeck.c:13418: invalid cast from 'NULL' type None to type FILE
cobc: aborting compile of create-sort-crash-report-this.cob at line 96 (PROGRAM-ID: INDEX-SORT)
cobc: Please report this!
Aborted (core dumped)
Reason is the missing file assignment (*> SELECT SORT-DATEI ASSIGN TO DISK.) in this part of code:
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT DATEN-DATEI ASSIGN TO "daten.dat"
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS DATEN-SCHLUESSEL
FILE STATUS IS DATEN-STATUS.
*> SELECT SORT-DATEI ASSIGN TO DISK.**
SELECT SORT-AUSGABE ASSIGN TO "sortout.dat".
DATA DIVISION.
FILE SECTION.
FD DATEN-DATEI.
01 DATEN-SATZ.
05 DATEN-SCHLUESSEL PIC X(10).
05 DATEN-INHALT PIC X(50).
SD SORT-DATEI.
01 SORT-SATZ.
05 SORT-SCHLUESSEL PIC X(10).
05 SORT-INHALT PIC X(50).
FD SORT-AUSGABE.
01 SORT-AUSGABE-SATZ.
05 AUSGABE-SCHLUESSEL PIC X(10).
05 AUSGABE-INHALT PIC X(50).
See attached similar error messages from Ubuntu (SVN 5546), MINGW (Snapshot r5567M from Chuck Haatvedt) and MSYS2-UCRT64 (official package).
Bad code (create-sort-crash-report-this.cob) and compiling code (create-sort-ok.cob) with proper "SELECT SORT-DATEI ASSIGN TO DISK." is attached, too.
PS: gcobol (gcc-15) and Rocket Visual Cobol (Micro Focus 10.0) recover both from this compilation error without a crash.
Thanks for the well done error report!
GC 3.2 and 3.3.dev directly crash with a segmentation fault.
The 3.3 dev ubuntu build was build with
--enable-cobc-internal-checksand recognizes that there's something which should not be the case and aborts itself (better, but still no recovery, most likely also possible with 3.2).Fixed with [r5587]/[r5588].
Related
Commit: [r5587]
Commit: [r5588]
Thanks for the fix. It works very well. I compiled svn revision 5588 under Ubuntu 24.04 with gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0 and make check and make test are both green.
My buggy code now runs into good messages without a crash :-)