Menu

#1151 cobc aborts without recovering because missing file assignment

GC 3.x
closed
3
2025-10-20
2025-10-13
No

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.

5 Attachments

Discussion

  • Simon Sobisch

    Simon Sobisch - 2025-10-17
    • labels: --> SD, SORT, error-recovery
    • status: open --> closed
    • assigned_to: Simon Sobisch
    • Priority: 5 - default --> 3
     
  • Simon Sobisch

    Simon Sobisch - 2025-10-17

    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]

  • Michael Del Solio

    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 :-)

    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
    create-sort-crash-report-this.cob: in paragraph 'DATEN-SCHREIBEN':
    create-sort-crash-report-this.cob:105: error: 'SORT-DATEI' is not a file name
      103 |            OPEN OUTPUT SORT-AUSGABE
      104 |            PERFORM UNTIL EXIT
      105 >                RETURN SORT-DATEI RECORD
      106 |                    AT END EXIT PERFORM
      107 |                END-RETURN
    
    cobc -v
    cobc (GnuCOBOL) 3.3-dev.0
    Built     Oct 20 2025 11:31:35  Packaged  Oct 17 2025 20:32:16 UTC
    C version "13.3.0"
    loading standard configuration file 'default.conf'
    cobc: error: no input files
    
     

Log in to post a comment.

MongoDB Logo MongoDB