<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Cobol program crashes sorting an empty array. Bug or other ? in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/cobol-program-crashes-sorting-an-empty-array-bug-or-other/m-p/3912748#M35265</link>
    <description>To appease my unnamed, shy but vocal, pedantic friends:-) Of course, I meant: "The sort [should have] succeeded; it was given nothing to sort and it [should] return nothing sorted [rather than error out, as it did].&lt;BR /&gt;&lt;BR /&gt;&lt;JOHN gillings=""&gt;&lt;BR /&gt;1) By definition a 0 length array has no valid subscripts so any attempt to access the array should fail with subscript out of bounds. What else could an access attempt return?&lt;BR /&gt;&lt;/JOHN&gt;&lt;BR /&gt;&lt;BR /&gt;But, 0 is a valid run-time array length value. We load an array with a variable &amp;amp; unknown number of elements so we can sort it. In this case, we loaded it with 0 elements. That the language-provided sort routine subscripted using that 0, -F-ailed, and stack dumped can't be considered the desired behavior.&lt;BR /&gt;&lt;BR /&gt;&lt;JG&gt;&lt;BR /&gt;2) The only other possible result from the SORT operation would be returning silently.&lt;BR /&gt;&lt;/JG&gt;&lt;BR /&gt;&lt;BR /&gt;Yes. That would be the correct result.&lt;BR /&gt;&lt;BR /&gt;&lt;JG&gt;&lt;BR /&gt;That could be obscuring a logic error in the program. Any programmer who WANTS that behaviour can easily conditionalise it with "IF num_sig_dates GREATER THAN ZERO THEN".&lt;BR /&gt;&lt;/JG&gt;&lt;BR /&gt;&lt;BR /&gt;The caller logic probably will do something "special" if nothing is loaded into the array, or maybe the program will fail someplace else. It's not the sort routine's place to worry about that.&lt;BR /&gt;&lt;BR /&gt;The programmer, *might* use "IF num_sig_dates GREATER THAN ONE THEN" to conditionalize the sort, but it seems reasonable that the sort routine *should* check whether the array length is greater than one before doing anything else. &lt;BR /&gt;&lt;BR /&gt;&lt;JG&gt;&lt;BR /&gt;On the other hand, this kind of edge condition is always debatable.&lt;BR /&gt;&lt;/JG&gt;&lt;BR /&gt;&lt;BR /&gt;There can be no debate that it's an out-of-bounds condition error, but the error is within the sort logic and not the calling program. Zero is within the bounds of possible array lengths.&lt;BR /&gt;&lt;BR /&gt;Like the C buffer overflow bug, which has been similarly debated, the solution is to correct it "internally" at the point of failure. (I'll probably be sorry I brought that up!;-)&lt;BR /&gt;</description>
    <pubDate>Tue, 19 Dec 2006 17:35:08 GMT</pubDate>
    <dc:creator>Doug Phillips</dc:creator>
    <dc:date>2006-12-19T17:35:08Z</dc:date>
    <item>
      <title>Cobol program crashes sorting an empty array. Bug or other ?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/cobol-program-crashes-sorting-an-empty-array-bug-or-other/m-p/3912741#M35258</link>
      <description>A COBOL program crashes when trying to sort an empty array. The programmer has the view this is a complier problem and not a programming problem.&lt;BR /&gt;&lt;BR /&gt;Here is a reproducer and the accompanying error message.&lt;BR /&gt;&lt;BR /&gt;identification division.&lt;BR /&gt;program-id. testsort2.&lt;BR /&gt;author. Programmer.&lt;BR /&gt;date-compiled.&lt;BR /&gt;&lt;BR /&gt;environment division.&lt;BR /&gt;configuration section.&lt;BR /&gt;source-computer.        vax.&lt;BR /&gt;object-computer.        vax.&lt;BR /&gt;special-names.&lt;BR /&gt;data division.&lt;BR /&gt;&lt;BR /&gt;working-storage section.&lt;BR /&gt;01 num_sig_dates                                    pic s9(9) comp value 0.&lt;BR /&gt;01 sig_date_tbl.&lt;BR /&gt;    03 sig_date occurs 0 to 100 times depending on num_sig_dates    pic x(50).&lt;BR /&gt;&lt;BR /&gt;procedure division.&lt;BR /&gt;start-up.&lt;BR /&gt;          sort sig_date&lt;BR /&gt;               on ascending sig_date.&lt;BR /&gt;&lt;BR /&gt;        stop run.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;$ COBOL/CHECK=(ALL,NOPERFORM,NODUPLICATE)/NOALIGN TESTSORT&lt;BR /&gt;$ link testsort &lt;BR /&gt;&lt;BR /&gt;$ r testsort&lt;BR /&gt;%COB-F-SUBSCRIPT, Subscript out of bounds&lt;BR /&gt;%TRACE-F-TRACEBACK, symbolic stack dump follows&lt;BR /&gt;  image    module    routine             line      rel PC           abs PC      &lt;BR /&gt; DEC$COBRTL                                 0 0000000000000ECC 000000007C322ECC&lt;BR /&gt; DEC$COBRTL                                 0 000000000003603C 000000007C35803C&lt;BR /&gt;----- above condition handler called with exception 0000056C:&lt;BR /&gt;%SYSTEM-F-RANGEERR, range error, PC=0000000000030118, PS=0000001B&lt;BR /&gt;----- end of exception message&lt;BR /&gt;                                            0 FFFFFFFF8009C09C FFFFFFFF8009C09C&lt;BR /&gt; TESTSORT  TESTSORT2  TESTSORT2            20 0000000000000118 0000000000030118&lt;BR /&gt; TESTSORT                                   0 00000000000304A0 00000000000304A0&lt;BR /&gt;                                            0 FFFFFFFF80269ED4 FFFFFFFF80269ED4&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;What is your opinion? Complier problem or programming bug?&lt;BR /&gt;</description>
      <pubDate>Thu, 14 Dec 2006 00:05:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/cobol-program-crashes-sorting-an-empty-array-bug-or-other/m-p/3912741#M35258</guid>
      <dc:creator>Thomas Ritter</dc:creator>
      <dc:date>2006-12-14T00:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: Cobol program crashes sorting an empty array. Bug or other ?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/cobol-program-crashes-sorting-an-empty-array-bug-or-other/m-p/3912742#M35259</link>
      <description>Thomas,&lt;BR /&gt;&lt;BR /&gt;  I'd say programming bug. Two reasons...&lt;BR /&gt;&lt;BR /&gt;1) By definition a 0 length array has no valid subscripts so any attempt to access the array should fail with subscript out of bounds. What else could an access attempt return? &lt;BR /&gt;&lt;BR /&gt;2) The only other possible result from the SORT operation would be returning silently. That could be obscuring a logic error in the program. Any programmer who WANTS that behaviour can easily conditionalise it with "IF num_sig_dates GREATER THAN ZERO THEN".&lt;BR /&gt;&lt;BR /&gt;  On the other hand, this kind of edge condition is always debatable. My preference is for the onus to be on the programmer to be very explicit about how it should be handled. Anything even slightly questionable should be complained about. Compilers "being nice", and making assumptions about how non-sensical requests should be handled is a source of many bugs!&lt;BR /&gt;</description>
      <pubDate>Thu, 14 Dec 2006 00:32:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/cobol-program-crashes-sorting-an-empty-array-bug-or-other/m-p/3912742#M35259</guid>
      <dc:creator>John Gillings</dc:creator>
      <dc:date>2006-12-14T00:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: Cobol program crashes sorting an empty array. Bug or other ?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/cobol-program-crashes-sorting-an-empty-array-bug-or-other/m-p/3912743#M35260</link>
      <description>Thomas,&lt;BR /&gt;&lt;BR /&gt;  Forgot to add... if you want an authoritative answer, please log a case with your local customer support centre ;-)</description>
      <pubDate>Thu, 14 Dec 2006 19:16:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/cobol-program-crashes-sorting-an-empty-array-bug-or-other/m-p/3912743#M35260</guid>
      <dc:creator>John Gillings</dc:creator>
      <dc:date>2006-12-14T19:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: Cobol program crashes sorting an empty array. Bug or other ?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/cobol-program-crashes-sorting-an-empty-array-bug-or-other/m-p/3912744#M35261</link>
      <description>The clue is the COBOL/CHECK=ALL switch. I will log a call. &lt;BR /&gt;&lt;BR /&gt;If we compile without CHECK=ALL there is no stack dump. However the programmers insist on using CHECK=ALL to check for other out of bound problems. &lt;BR /&gt;&lt;BR /&gt;Thomas</description>
      <pubDate>Sun, 17 Dec 2006 17:36:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/cobol-program-crashes-sorting-an-empty-array-bug-or-other/m-p/3912744#M35261</guid>
      <dc:creator>Thomas Ritter</dc:creator>
      <dc:date>2006-12-17T17:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: Cobol program crashes sorting an empty array. Bug or other ?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/cobol-program-crashes-sorting-an-empty-array-bug-or-other/m-p/3912745#M35262</link>
      <description>Well, the manual isn't too clear on whether a zero length table is legal.  I'll check more on it when I return (I'm leaving on vacation on Wednesday and won't return until after the first of the year).  In the meantime, "don't do that".&lt;BR /&gt;&lt;BR /&gt;John&lt;BR /&gt;COBOL Project Leader</description>
      <pubDate>Mon, 18 Dec 2006 17:31:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/cobol-program-crashes-sorting-an-empty-array-bug-or-other/m-p/3912745#M35262</guid>
      <dc:creator>John Reagan</dc:creator>
      <dc:date>2006-12-18T17:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: Cobol program crashes sorting an empty array. Bug or other ?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/cobol-program-crashes-sorting-an-empty-array-bug-or-other/m-p/3912746#M35263</link>
      <description>This is the standard way Cobol is complied&lt;BR /&gt;&lt;BR /&gt;COBOL/CHECK=(ALL,NOPERFORM,NODUPLICATE)/NOALIGN TESTSORT&lt;BR /&gt;</description>
      <pubDate>Mon, 18 Dec 2006 17:39:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/cobol-program-crashes-sorting-an-empty-array-bug-or-other/m-p/3912746#M35263</guid>
      <dc:creator>Thomas Ritter</dc:creator>
      <dc:date>2006-12-18T17:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: Cobol program crashes sorting an empty array. Bug or other ?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/cobol-program-crashes-sorting-an-empty-array-bug-or-other/m-p/3912747#M35264</link>
      <description>I'd call it a bug in the cobol sort. The sort succeeded; it was give nothing to sort and it returned nothing sorted. If it is given 1 thing to sort does it error out, even though it does no work? DCL sort doesn't error out when given an empty input file; it returns an empty output file, not an error.&lt;BR /&gt;</description>
      <pubDate>Tue, 19 Dec 2006 14:02:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/cobol-program-crashes-sorting-an-empty-array-bug-or-other/m-p/3912747#M35264</guid>
      <dc:creator>Doug Phillips</dc:creator>
      <dc:date>2006-12-19T14:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: Cobol program crashes sorting an empty array. Bug or other ?</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/cobol-program-crashes-sorting-an-empty-array-bug-or-other/m-p/3912748#M35265</link>
      <description>To appease my unnamed, shy but vocal, pedantic friends:-) Of course, I meant: "The sort [should have] succeeded; it was given nothing to sort and it [should] return nothing sorted [rather than error out, as it did].&lt;BR /&gt;&lt;BR /&gt;&lt;JOHN gillings=""&gt;&lt;BR /&gt;1) By definition a 0 length array has no valid subscripts so any attempt to access the array should fail with subscript out of bounds. What else could an access attempt return?&lt;BR /&gt;&lt;/JOHN&gt;&lt;BR /&gt;&lt;BR /&gt;But, 0 is a valid run-time array length value. We load an array with a variable &amp;amp; unknown number of elements so we can sort it. In this case, we loaded it with 0 elements. That the language-provided sort routine subscripted using that 0, -F-ailed, and stack dumped can't be considered the desired behavior.&lt;BR /&gt;&lt;BR /&gt;&lt;JG&gt;&lt;BR /&gt;2) The only other possible result from the SORT operation would be returning silently.&lt;BR /&gt;&lt;/JG&gt;&lt;BR /&gt;&lt;BR /&gt;Yes. That would be the correct result.&lt;BR /&gt;&lt;BR /&gt;&lt;JG&gt;&lt;BR /&gt;That could be obscuring a logic error in the program. Any programmer who WANTS that behaviour can easily conditionalise it with "IF num_sig_dates GREATER THAN ZERO THEN".&lt;BR /&gt;&lt;/JG&gt;&lt;BR /&gt;&lt;BR /&gt;The caller logic probably will do something "special" if nothing is loaded into the array, or maybe the program will fail someplace else. It's not the sort routine's place to worry about that.&lt;BR /&gt;&lt;BR /&gt;The programmer, *might* use "IF num_sig_dates GREATER THAN ONE THEN" to conditionalize the sort, but it seems reasonable that the sort routine *should* check whether the array length is greater than one before doing anything else. &lt;BR /&gt;&lt;BR /&gt;&lt;JG&gt;&lt;BR /&gt;On the other hand, this kind of edge condition is always debatable.&lt;BR /&gt;&lt;/JG&gt;&lt;BR /&gt;&lt;BR /&gt;There can be no debate that it's an out-of-bounds condition error, but the error is within the sort logic and not the calling program. Zero is within the bounds of possible array lengths.&lt;BR /&gt;&lt;BR /&gt;Like the C buffer overflow bug, which has been similarly debated, the solution is to correct it "internally" at the point of failure. (I'll probably be sorry I brought that up!;-)&lt;BR /&gt;</description>
      <pubDate>Tue, 19 Dec 2006 17:35:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/cobol-program-crashes-sorting-an-empty-array-bug-or-other/m-p/3912748#M35265</guid>
      <dc:creator>Doug Phillips</dc:creator>
      <dc:date>2006-12-19T17:35:08Z</dc:date>
    </item>
  </channel>
</rss>

