Menu

#12 BWBasic 3.2 freezes after entering run#

v1.0 (example)
open
nobody
None
5
2023-04-23
2023-03-18
Oliver
No

I wrote a small BASIC listing and accidentally pressed the "#" key before pressing the return key after i entered run. The result was, that the BWBASIC interpreter freezes when run# is entered instead of run.

The "#" key is next to the "RETURN" key on a German keyboard layout. Therefore, it is not difficult to accidentally press it when trying to press RETURN.

Discussion

  • AF5NE

    AF5NE - 2023-04-18

    Thanks for finding this bug. Sorry for the delay in responding - I am not often online. If you are comfortable updating the source code with diff/patch, the attached "patch-20230417.txt" should fix this bug and all the other bugs I know about.

    If you are not comfortable with diff/patch, then open "bwb_cmd.c" with a text editor and goto to around line 1555, which should look like this:

       if (line_read_expression (L, X) == FALSE)        /* bwb_run_filename_or_linenumber */
       {
         WARN_SYNTAX_ERROR;
         return L;
       }
    

    Update that section to this:

      if (line_read_expression (L, X) == FALSE)        /* bwb_run_filename_or_linenumber */
      {
        WARN_SYNTAX_ERROR;
    /*
    Bug #12 BWBasic 3.2 freezes after entering run#
    */
    L = NULL;
        return L;
      }
    

    After recompiling the following test confirms that bug is fixed.

    bwBASIC: LIST
      100 REM RUN
      110 PRINT "TEST RUN # 200"
      120 RUN # 200
      130 PRINT "FAILED @ 130"
      140 END
      200 PRINT "PASSED @ 200"
      999 END
    bwBASIC: RUN
    TEST RUN # 200
    PASSED @ 200
    bwBASIC: RUN #200
    PASSED @ 200
    bwBASIC: RUN # 200
    PASSED @ 200
    bwBASIC: RUN #
    ERROR: Syntax error
    bwBASIC: RUN#
    ERROR: Syntax error
    bwBASIC: RUN 200
    PASSED @ 200
    
     
    • Oliver

      Oliver - 2023-04-18

      Thank you a lot for fixing that bug. Your fix worked. But i found another bug that is related to this bug.

      BWBasic freezes when trying to run code starting with a line number that is not in the code listing.
      I used your code listing example above and entered:

        run 150
      

      And after pressing the return key, BWBasic freezes. See the screenshot below.
      The same applies for variants like this one:

        run # 150
      

      or

        run #150
      

      I added your fix manually. I didn't use the diff patch because I didn't have the appropriate diff software installed in FreeDOS 1.3.

       

      Last edit: Oliver 2023-04-18
    • Oliver

      Oliver - 2023-04-18

      As an additional information to my last comment:

      I was curious how GW-BASIC reacts when entering a line number that doesn't exist.
      When trying to do so, it prints the line:

        Undefined line number
        OK
      

      And returns to the GW-BASIC interpreter.
      See screenshot as an example:

       

      Last edit: Oliver 2023-04-18
    • Oliver

      Oliver - 2023-04-18

      One more information.

      I found out that it is possible to switch back to the interpreter by pressing
      CTRL + C when a none existing line number was given to run the basic code.

      The problem with this is, BWBasic returns to the interpreter only, when only a number like

      run 150
      

      was given and the keys CTRL+C was pressed

      If i enter a number with a # character

      run # 150
      

      and then press the CTRL+C key, then BWBasic exists or crashes to DOS prompt.

      But from there, the memory seems to be rather corrupted, because additional DOS commands, for example

      mem
      

      do throw an exception.
      Thus BWBasic doesn't exit in a clean way at this point.

      See the screenshots for example.

       

      Last edit: Oliver 2023-04-18
  • AF5NE

    AF5NE - 2023-04-20

    Glad the initial bug is fixed. The attached "patch-20230419.txt" should fix the second bug you reported above.

     
  • AF5NE

    AF5NE - 2023-04-20

    After recompiling the following test should confirm the second bug is fixed.

    bwBASIC: REM TEST 'RUN' COMMAND
    bwBASIC: 
    bwBASIC: 
    bwBASIC: LIST
      100 PRINT "HELLO"
    
    bwBASIC: SAVE "GOOD.BAS"
    bwBASIC: 
    bwBASIC: 
    bwBASIC: REM THESE SHOULD DISPLAY "HELLO"
    bwBASIC: 
    bwBASIC: 
    bwBASIC: RUN
    HELLO
    bwBASIC: RUN 100
    HELLO
    bwBASIC: RUN#100
    HELLO
    bwBASIC: RUN "GOOD.BAS"
    HELLO
    bwBASIC: 
    bwBASIC: 
    bwBASIC: REM THESE SHOULD DISPLAY AN ERROR MESSAGE
    bwBASIC: 
    bwBASIC: 
    bwBASIC: RUN 1
    
    ERROR: Undefined line
    bwBASIC: RUN 999
    
    ERROR: Undefined line
    bwBASIC: RUN#
    
    ERROR: Syntax error
    bwBASIC: RUN#1
    
    ERROR: Undefined line
    bwBASIC: RUN#999
    
    ERROR: Undefined line
    bwBASIC: RUN ""
    
    ERROR: Bad file name
    bwBASIC: RUN "BOGUS.BAS" 
    
    ERROR: Bad file name
    bwBASIC: 
    bwBASIC: 
    bwBASIC: REM CREATE A FILE CONTAINING ERRORS
    bwBASIC: 
    bwBASIC: 
    bwBASIC: NEW
    bwBASIC: OPEN "BAD.BAS" FOR OUTPUT AS #1
    bwBASIC: PRINT #1, "100 NO SUCH COMMAND"
    bwBASIC: CLOSE #1
    bwBASIC: 
    bwBASIC: 
    bwBASIC: REM THIS SHOULD DISPLAY AN ERROR MESSAGE
    bwBASIC: 
    bwBASIC: 
    bwBASIC: RUN "BAD.BAS" 
    ILLEGAL COMMAND AFTER LINE NUMBER: 100 NO SUCH COMMAND
    
    ERROR in line 100: Illegal direct
    
    STACK TRACE:
    100:NO SUCH COMMAND
    bwBASIC: 
    bwBASIC: 
    bwBASIC: REM THIS SHOULD *NOT* DISPLAY AN ERROR MESSAGE
    bwBASIC: 
    bwBASIC: 
    bwBASIC: NEW
    bwBASIC: RUN
    bwBASIC: 
    bwBASIC: 
    bwBASIC: REM CLEANUP
    bwBASIC: 
    bwBASIC: 
    bwBASIC: KILL "GOOD.BAS"
    bwBASIC: KILL "BAD.BAS"
    
     
    • Oliver

      Oliver - 2023-04-23

      Thank you very much.
      I can report that your second patch fixed the second bug.
      I did your test and everything worked like it should.
      Great work!

       

Log in to post a comment.