Menu

#797 changeformat issue with empty lines

contrib
closed
None
5 - default
2022-01-03
2021-12-28
David Wall
No

It would appear that the program doesn't like blank lines in a free format source file when trying to convert that file to a fixed format.
The reverse isn't true - it's quite happy to convert a fixed format file with blank lines to a free format file.

I have attached the simplest source prog to demonstrate.
As soon as it reaches a blank line it crashes.

1 Attachments

Discussion

  • Vincent (Bryan) Coen

    Tested using your sample see below :

    cobc -V
    cobc (GnuCOBOL) 3.1.2.0
    Built Dec 17 2021 17:51:35
    Packaged Dec 23 2020 12:04:58 UTC
    C version "10.3.0"

    changeformat soha.cob soha-cbl tofixed
    chgfmt v1.00.04 Completed successfully

    See soha.cbl

    Looks correct to me !

     
    • David Wall

      David Wall - 2021-12-28

      Well I just ran it again with both the file you sent me and the original I uploaded & it crashed again on both.

      What's the size of the .cbl source of changeformat ?? - I have 53,822.

      By the way - I'm compiling using 3.2 - I'll try with 3.1.

      That's the problem - it works with 3.1 but not with 3.2 - out of bounds every time.

      Crashes at line 549 - see my original comments on the contributions board.

       

      Last edit: David Wall 2021-12-28
      • Vincent (Bryan) Coen

        I show 42182 for both my internal copy and in contribs which is dated
        3rd August 2020

        Version is 1.0.04 last updated by Simon.

        Vince

        On 28/12/2021 14:03, David Wall wrote:

        Well I just ran it again with both the file you sent me and the
        original I uploaded & it crashed again on both.

        What's the size of the .cbl source of changeformat ?? - I have 53,822.

        By the way - I'm compiling using 3.2 - I'll try with 3.1.

        That's the problem - it works with 3.1 but not with 3.2 - out of
        bounds every time.

         
  • Vincent (Bryan) Coen

    • status: open --> pending
     
  • Simon Sobisch

    Simon Sobisch - 2021-12-28

    This gets interesting, I assume that both were compiled with --debug (or the implied -fec=all). Note: [e8f43ee517] was the origin of this issue with the output

    libcob: changeformat.cob:549: error: subscript of 'WORD-TYPE' out of bounds: 0
    libcob: changeformat.cob:549: warning: implicit CLOSE of INPUT-FILE ('desimake.COB')
    libcob: changeformat.cob:549: warning: implicit CLOSE of OUTPUT-FILE ('desimake.FIX')
     Last statement of "changeformat" was at line 549 of changeformat.cob
     Started by changeformat
                desimake.COB
                desimake.FIX
                TOFIXED
    

    So without looking at the code - possibly skip whatever is done in line 549 if WORD-TYPE EQUALS 0?

     

    Related

    Discussion: e8f43ee517

  • David Wall

    David Wall - 2021-12-28

    The version in trunk tools shows the following:
    changeformat-f.cbl 2021-02-20 vcoen [r932] Added source for fixed format version as change...

    It's got your name against Vince it as opposed to the one following it:
    changeformat.cbl 2019-09-12 sf-mensch [r769] tool changeformat: fixed compiler warning ...
    which has Simons name.

    I picked the latest dated version with I presume the latest r number.

    It was compiled with -d & -ftraceall

    Regarding the skip whatever code is done in 549 - I tried that but got another error:

    35 open failure soh.COB
    libcob: changeformat.cob:413: warning: implicit CLOSE of OUTPUT-FILE ('soh.FIX')

    I give up.

     

    Related

    Commit: [r932]

  • Vincent (Bryan) Coen

    Please compile with cobc -x changeformat.cbl and rerun your test.

     
    • Simon Sobisch

      Simon Sobisch - 2021-12-28

      @vcoen: Please recompile with cobc -x --debug changeformat.cbl and rerun your test.

       
      • Vincent (Bryan) Coen

        On 28/12/2021 17:43, Simon Sobisch wrote:

        @vcoen https://sourceforge.net/u/vcoen/: Please recompile with |cobc
        -x --debug changeformat.cbl| and rerun your test.

        I already have tried that and yes that fails and looking at the code it
        does NOT test for out of range i.e., = 0 or > that array size but it is
        not my code so do not know what it is doing.

        Easier just to not use the debug flags when building it is no -d -g.

         
  • David Wall

    David Wall - 2021-12-28

    @sf-mensch & @vcoen It's easier to forget GnuCOBOL 3.2 completely & run it under 3.1 where at least it runs to completion and appears to do the right thing (at least on my source files).

    If and when 3.2 gets released to the wild then I expect this will be revisited by one or other of you.

     
  • Vincent (Bryan) Coen

    As operation using gc v3.1 series I will close this BR.

     
  • Vincent (Bryan) Coen

    • status: pending --> closed
     
  • Simon Sobisch

    Simon Sobisch - 2022-01-03
    • summary: changeformat --> changeformat issue with empty lines
     
  • Simon Sobisch

    Simon Sobisch - 2022-01-03

    Just as a follow-up: @chaat was so kind to re-inspect and fixed the code issues in changeformat with [contrib:r986] and [contrib:r985]+[contrib:r987] after he verified that "newer" GnuCOBOL versions do a better job with runtime checks enabled than the previous ones.
    As far as I know using the new version of changeformat should work with runtime checks enabled.

     

    Related

    Commit: [r985]
    Commit: [r986]
    Commit: [r987]


Log in to post a comment.