Menu

#830 cobc: Please report this! (Error 11)

GC 3.2
duplicate
5 - default
2022-05-15
2022-05-15
No

Hi,

Trying to compile a program I received an Error 11 with a notification requesting that I please report the error.

My compiler options were:
cobc -std=cobol2014 -debug -W -fimplicit-init -O2 -c src/main/ff-via-printf.cob -o build/release/ff-via-printf-1.0.o

ff-via-printf.cob contains:

GNU   *> >> source format is fixed
COBOL *> ***************************************************************
      *> File:     ff-via-printf.cob
      *> SPDX-License-Identifier: MIT
      *> Copyright (c) 2022, Justin Hanekom
      *> Description: Writes two rows of float numbers to the output
      *>              file, outfile.
      *>
      *> ***************************************************************
      *>  Date  Change Description
      *> ====== ==================
      *> jh2204 Initial release
      *>
      *> ***************************************************************
       identification division.
  id   program-id. ff-via-printf.

 site  environment division.
       configuration section.
       repository.
           function all intrinsic.

       input-output section.
       file-control.
           select outfile-floats
           assign to "floats.txt"
           organization is line sequential
           file status is ws01-outfile-status.

 data  data division.
 file  file section.
       fd  outfile-floats.
       01  outfile-record              pic x(80) value all spaces.

store  working-storage section.
       01  a01-row                     binary-long.

       01  c01-result-success          constant as 0.
       01  c05-result-unknown-err      constant as -1.

       01  ws01-outfile-status         pic x(2).
       01  ws05-x-precision            pic 9(2)  value 0.
       01  ws10-y-precision            pic 9(2)  value 0.
       01  ws15-print-format           pic x(15) value all spaces.
       01  ws20-print-buffer           pic x(80) value all spaces.

 link  linkage section.
       01  l01-outfile-name            pic x(11).
       01  l05-num-rows                binary-long.
       01  l10-x-table.
           05  l10-x-values            occurs 0 to 100000 times
                                       depending on l05-num-rows.
               10  l10-x               float-long.
       01  l15-y-table.
           05  l15-y-values            occurs 0 to 100000 times
                                       depending on l05-num-rows.
               10  l15-y               float-long.
       01  l20-x-precision             pic 9(2).
       01  l25-y-precision             pic 9(2).
       01  l30-result                  binary-long.
      /
      *> ***************************************************************
 code  procedure division
           using l01-outfile-name
                 l05-num-rows
                 l10-x-table
                 l15-y-table
                 l20-x-precision
                 l25-y-precision
                 l30-result
       .
 decl  declaratives.

      *> ---------------------------------------------------------------
      *> The **outfile-floats-errors section responds to errors that
      *> occur with outfile-floats.
      *> ---------------------------------------------------------------
       outfile-floats-errors section.
           use after standard error on outfile-floats.

       show-outfile-floats-error.
           display "An error occurred with the outfile-floats file."
               upon stderr
           end-display
           .

       end declaratives.

      *> ===============================================================
      *> The **mainline** section is the program entry point.
      *> ===============================================================
 main  mainline section.
           perform 100-initialize
           perform 200-print-arrays
           perform 800-done
           .

      *> ===============================================================
      *> The **100-initialize** section initializes any data division
      *> entries that need to be initialized.
      *> ===============================================================
 init  100-initialize section.
       >>D ready trace
           move c05-result-unknown-err to l30-result

           *> open output-floats
           open output sharing with read only outfile-floats
           if ws01-outfile-status greater than 10
               perform 910-display-hard-exception
           end-if

           *> initialize the print format
           move l20-x-precision to ws05-x-precision
           move l25-y-precision to ws10-y-precision
           string "%."
                  trim(ws05-x-precision)
                  "g" x"09" "%."
                  trim(ws10-y-precision)
                  "g"
               into ws15-print-format
               on overflow perform 910-display-hard-exception
       >>D     not on overflow
       >>D         display "Print formatting will be: "
       >>D             trim(ws15-print-format)
       >>D             upon stderr
       >>D         end-display
           end-string
       >>D reset trace
           .

      *> ===============================================================
      *> The **200-print-arrays** section prints the `l05-num-rows`
      *> values in the `l10-x-table` and `l15-y-table`, to the file
      *> `l01outfile-name`. The x-vals are given the `l20-x-precision`
      *> precision, and the y-vals the `l25-y-precision` precision.
      *> ===============================================================
print  200-print-arrays section.
           perform varying a01-row
                   from 1 by 1
                   until a01-row > l05-num-rows
               move all spaces to ws20-print-buffer
               call "sprintf"
                   using
                       by reference ws20-print-buffer
                                    ws15-print-format
                       by value     l10-x (a01-row)
                                    l15-y (a01-row)
                   returning omitted
               end-call
               move ws20-print-buffer to outfile-record
               write outfile-record end-write
       >>D     display
       >>D         l10-x (a01-row) " = " l15-y (a01-row)
       >>D     end-display
            end-perform
           .

      *> ===============================================================
      *> The **800-done** section finalizes the result sent to the
      *> calling program and returns to the calling program.
      *> ===============================================================
 done  800-done section.
       >>D ready trace
           close outfile-floats
           move c01-result-success to l30-result
       >>D reset trace
           perform 890-exit
           .

      *> ---------------------------------------------------------------
      *> **890-exit** exists this program and returns to the calling
      *> program.
      *> ---------------------------------------------------------------
       890-exit.
 exit      goback.

      /
      *> ===============================================================
      *> **900-display-exception** provides details of warnings
      *> and abends.
      *> ===============================================================
       900-display-exception section.

      *> ---------------------------------------------------------------
      *> **910-display-hard-exception** displays details of the hard
      *> exception that has just occurred and then terminates the
      *> program with the error result code `127`.
      *> ---------------------------------------------------------------
 fail  910-display-hard-exception.
           perform 920-display-soft-exception
           stop run returning 127
           .

      *> ---------------------------------------------------------------
      *> **920-display-soft-exception** displays details of the
      *> soft exception that has just occurred.
      *> ---------------------------------------------------------------
 warn  920-display-soft-exception.
               display
                   "Exception-file:      " exception-file
                   upon syserr
               end-display
               display
                   "Exception-status:    " exception-status
                   upon syserr
               end-display
               display
                   "Exception-location:  " exception-location
                   upon syserr
               end-display
               display
                   "Exception-statement: " exception-statement
                   upon syserr
               end-display
               .

       end program ff-via-printf.

The compiler returns:

attempt to reference unallocated memory (signal SIGSEGV)

cobc: aborting compile of src/main/ff-via-printf.cob at line 103 (unknown: unknown)
cobc: Please report this!

Any help would be appreciated!

Regards,
Justin Hanekom

1 Attachments

Related

Bugs: #830

Discussion

  • Simon Sobisch

    Simon Sobisch - 2022-05-15
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,12 +1,12 @@
     Hi,
    
    -Trying to compile a program I received an Error 11 with a notification requesting that I pleas report the error.
    +Trying to compile a program I received an Error 11 with a notification requesting that I please report the error.
    
     My compiler options were:
    -cobc  -std=cobol2014 -debug -W -fimplicit-init -O2 -c src/main/ff-via-printf.cob -o build/release/ff-via-printf-1.0.o
    +`cobc  -std=cobol2014 -debug -W -fimplicit-init -O2 -c src/main/ff-via-printf.cob -o build/release/ff-via-printf-1.0.o`
    
     ff-via-printf.cob contains:
    -****************************************
    +```cobolfree
     GNU   *> >> source format is fixed
     COBOL *> ***************************************************************
           *> File:     ff-via-printf.cob
    @@ -224,13 +224,16 @@
                    .
    
            end program ff-via-printf.
    -****************************************
    +```
    
     The compiler returns:
    +
    +~~~
     attempt to reference unallocated memory (signal SIGSEGV)
    
     cobc: aborting compile of src/main/ff-via-printf.cob at line 103 (unknown: unknown)
     cobc: Please report this!
    +~~~
    
     Any help would be appreciated!
    
     
  • Simon Sobisch

    Simon Sobisch - 2022-05-15
    • labels: --> cobc, SIGSEGV
    • status: open --> duplicate
    • assigned_to: Simon Sobisch
    • Group: unclassified --> GC 3.2
     
    • Justin Hanekom

      Justin Hanekom - 2022-05-15

      Thank you Simon!

      I am using cobc version 3.1.2.0 (i.e., prior to 3.2-dev).

      Your answer explains why compiling this program with the additional options
      " -O -DDEBUG -g -fdebugging-line -fdebugging-mode=ok -ftraceall"
      for a debug version results in a successful compile.

      BTW I am an old hand, having been a professional developer since 1986, so I
      know only too well the value of a good bug report.

      Kindest regards,
      Justin

      On Sun, May 15, 2022 at 2:41 PM Simon Sobisch sf-mensch@users.sourceforge.net wrote:

      • labels: --> cobc, SIGSEGV
      • status: open --> duplicate
      • assigned_to: Simon Sobisch
      • Group: unclassified --> GC 3.2
      • Comment:

      Thank you for this good bug report.

      This one is solved already in GnuCOBOL 3.2-dev - it happens when you
      should get some message about dialect specific issues - in this case

      error: debugging indicator does not conform to COBOL 2014

      To get over the error add -fdebugging-mode=ok to your command line or
      compile with -std=default.

      The bug where this is tracked is [bugs:#821], solved by [r4572].


      ** [bugs:#830] cobc: Please report this! (Error 11)**

      Status: duplicate
      Group: GC 3.2
      Labels: cobc SIGSEGV
      Created: Sun May 15, 2022 04:46 PM UTC by Justin Hanekom
      Last Updated: Sun May 15, 2022 06:32 PM UTC
      Owner: Simon Sobisch
      Attachments:

      Hi,

      Trying to compile a program I received an Error 11 with a notification
      requesting that I please report the error.

      My compiler options were:
      cobc -std=cobol2014 -debug -W -fimplicit-init -O2 -c src/main/ff-via-printf.cob -o build/release/ff-via-printf-1.0.o

      ff-via-printf.cob contains:
      ```cobolfree
      GNU > >> source format is fixed
      COBOL
      > *********
      > File: ff-via-printf.cob
      > SPDX-License-Identifier: MIT
      > Copyright (c) 2022, Justin Hanekom
      > Description: Writes two rows of float numbers to the output
      > file, outfile.
      >
      > *********
      > Date Change Description
      > ====== ==================
      > jh2204 Initial release
      >
      >
      *********
      identification division.
      id program-id. ff-via-printf.

      site environment division.
      configuration section.
      repository.
      function all intrinsic.

         input-output section.
         file-control.
             select outfile-floats
             assign to "floats.txt"
             organization is line sequential
             file status is ws01-outfile-status.
      

      data data division.
      file file section.
      fd outfile-floats.
      01 outfile-record pic x(80) value all spaces.

      store working-storage section.
      01 a01-row binary-long.

         01  c01-result-success          constant as 0.
         01  c05-result-unknown-err      constant as -1.
      
         01  ws01-outfile-status         pic x(2).
         01  ws05-x-precision            pic 9(2)  value 0.
         01  ws10-y-precision            pic 9(2)  value 0.
         01  ws15-print-format           pic x(15) value all spaces.
         01  ws20-print-buffer           pic x(80) value all spaces.
      

      link linkage section.
      01 l01-outfile-name pic x(11).
      01 l05-num-rows binary-long.
      01 l10-x-table.
      05 l10-x-values occurs 0 to 100000 times
      depending on l05-num-rows.
      10 l10-x float-long.
      01 l15-y-table.
      05 l15-y-values occurs 0 to 100000 times
      depending on l05-num-rows.
      10 l15-y float-long.
      01 l20-x-precision pic 9(2).
      01 l25-y-precision pic 9(2).
      01 l30-result binary-long.
      /
      > **********
      code procedure division
      using l01-outfile-name
      l05-num-rows
      l10-x-table
      l15-y-table
      l20-x-precision
      l25-y-precision
      l30-result
      .
      decl declaratives.

        *> ---------------------------------------------------------------
        *> The **outfile-floats-errors section responds to errors that
        *> occur with outfile-floats.
        *> ---------------------------------------------------------------
         outfile-floats-errors section.
             use after standard error on outfile-floats.
      
         show-outfile-floats-error.
             display "An error occurred with the outfile-floats file."
                 upon stderr
             end-display
             .
      
         end declaratives.
      
        *> ===============================================================
        *> The **mainline** section is the program entry point.
        *> ===============================================================
      

      main mainline section.
      perform 100-initialize
      perform 200-print-arrays
      perform 800-done
      .

        *> ===============================================================
        *> The **100-initialize** section initializes any data division
        *> entries that need to be initialized.
        *> ===============================================================
      

      init 100-initialize section.
      >>D ready trace
      move c05-result-unknown-err to l30-result

             *> open output-floats
             open output sharing with read only outfile-floats
             if ws01-outfile-status greater than 10
                 perform 910-display-hard-exception
             end-if
      
             *> initialize the print format
             move l20-x-precision to ws05-x-precision
             move l25-y-precision to ws10-y-precision
             string "%."
                    trim(ws05-x-precision)
                    "g" x"09" "%."
                    trim(ws10-y-precision)
                    "g"
                 into ws15-print-format
                 on overflow perform 910-display-hard-exception
         >>D     not on overflow
         >>D         display "Print formatting will be: "
         >>D             trim(ws15-print-format)
         >>D             upon stderr
         >>D         end-display
             end-string
         >>D reset trace
             .
      
        *> ===============================================================
        *> The **200-print-arrays** section prints the `l05-num-rows`
        *> values in the `l10-x-table` and `l15-y-table`, to the file
        *> `l01outfile-name`. The x-vals are given the `l20-x-precision`
        *> precision, and the y-vals the `l25-y-precision` precision.
        *> ===============================================================
      

      print 200-print-arrays section.
      perform varying a01-row
      from 1 by 1
      until a01-row > l05-num-rows
      move all spaces to ws20-print-buffer
      call "sprintf"
      using
      by reference ws20-print-buffer
      ws15-print-format
      by value l10-x (a01-row)
      l15-y (a01-row)
      returning omitted
      end-call
      move ws20-print-buffer to outfile-record
      write outfile-record end-write
      >>D display
      >>D l10-x (a01-row) " = " l15-y (a01-row)
      >>D end-display
      end-perform
      .

        *> ===============================================================
        *> The **800-done** section finalizes the result sent to the
        *> calling program and returns to the calling program.
        *> ===============================================================
      

      done 800-done section.
      >>D ready trace
      close outfile-floats
      move c01-result-success to l30-result
      >>D reset trace
      perform 890-exit
      .

        *> ---------------------------------------------------------------
        *> **890-exit** exists this program and returns to the calling
        *> program.
        *> ---------------------------------------------------------------
         890-exit.
      

      exit goback.

        /
        *> ===============================================================
        *> **900-display-exception** provides details of warnings
        *> and abends.
        *> ===============================================================
         900-display-exception section.
      
        *> ---------------------------------------------------------------
        *> **910-display-hard-exception** displays details of the hard
        *> exception that has just occurred and then terminates the
        *> program with the error result code `127`.
        *> ---------------------------------------------------------------
      

      fail 910-display-hard-exception.
      perform 920-display-soft-exception
      stop run returning 127
      .

        *> ---------------------------------------------------------------
        *> **920-display-soft-exception** displays details of the
        *> soft exception that has just occurred.
        *> ---------------------------------------------------------------
      

      warn 920-display-soft-exception.
      display
      "Exception-file: " exception-file
      upon syserr
      end-display
      display
      "Exception-status: " exception-status
      upon syserr
      end-display
      display
      "Exception-location: " exception-location
      upon syserr
      end-display
      display
      "Exception-statement: " exception-statement
      upon syserr
      end-display
      .

         end program ff-via-printf.
      

      ```

      The compiler returns:

      ~~~
      attempt to reference unallocated memory (signal SIGSEGV)

      cobc: aborting compile of src/main/ff-via-printf.cob at line 103 (unknown:
      unknown)
      cobc: Please report this!
      ~~~

      Any help would be appreciated!

      Regards,
      Justin Hanekom


      Sent from sourceforge.net because you indicated interest in <
      https://sourceforge.net/p/gnucobol/bugs/830/>

      To unsubscribe from further messages, please visit <
      https://sourceforge.net/auth/subscriptions/>

       

      Related

      Bugs: #821
      Bugs: #830
      Commit: [r4572]

  • Simon Sobisch

    Simon Sobisch - 2022-05-15

    Thank you for this good bug report.

    This one is solved already in GnuCOBOL 3.2-dev - it happens when you should get some message about dialect specific issues - in this case

    error: debugging indicator does not conform to COBOL 2014

    To get over the error add -fdebugging-mode=ok to your command line or compile with -std=default.

    The bug where this is tracked is [bugs:#821], solved by [r4572].

     

    Related

    Bugs: #821
    Commit: [r4572]


Log in to post a comment.

Auth0 Logo