robhagemans / pcbasic

PC-BASIC - A free, cross-platform emulator for the GW-BASIC family of interpreters
http://www.pc-basic.org
Other
393 stars 48 forks source link

Crash when running `AUTO .` #230

Open PatchMixolydic opened 9 months ago

PatchMixolydic commented 9 months ago

Bug report

Problem

According to the documentation, AUTO . should provide automatic line numbering starting from the last program line stored. However, attempting to use it causes the interpreter to throw a TypeError.

Steps

  1. Start PC-BASIC.
  2. Execute AUTO ..

Program

10 AUTO .

Crash log

Crash log
PC-BASIC crash log
====================================================================================================
FATAL ERROR
version   2.0.5 [ unreleased ]
python    3.11.2 [64bit ELF] 
platform  Linux-6.1.0-9-amd64-x86_64-with-glibc2.36
interface VideoSDL2, AudioSDL2
statement :AUTO .

main.py:119, _run_session
api.py:149, interact
implementation.py:315, interact
implementation.py:365, _auto_step
TypeError: %d format: a real number is required, not bytes

This is a bug in PC-BASIC.
Sorry about that. You can help improve PC-BASIC:

- Please file a bug report, including this message and the steps you took
  just before the crash. Go to:
    https://github.com/robhagemans/pcbasic/issues

- Please include the full crash log in your report.
  You can paste it from the clipboard or from the file at:
    /home/patchmixolydic/.local/share/pcbasic-2.0/crash-20231119-t21nxalz.log
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pcbasic/guard.py", line 51, in protect
    yield
  File "/usr/lib/python3/dist-packages/pcbasic/main.py", line 119, in _run_session
    session.interact()
  File "/usr/lib/python3/dist-packages/pcbasic/basic/api.py", line 149, in interact
    self._impl.interact()
  File "/usr/lib/python3/dist-packages/pcbasic/basic/implementation.py", line 315, in interact
    self._auto_step()
  File "/usr/lib/python3/dist-packages/pcbasic/basic/implementation.py", line 365, in _auto_step
    numstr = b'%d' % (self._auto_linenum,)
             ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
TypeError: %d format: a real number is required, not bytes

==== Screen Pages ==================================================================================
   +--------------------------------------------------------------------------------+
 0 |PC-BASIC 2.0.5                                                                  | 14
 1 |(C) Copyright 2013--2022 Rob Hagemans.                                          | 38
 2 |60300 Bytes free                                                                | 16
 3 |Ok?                                                                             |  3
 4 |AUTO .                                                                          |  6
 5 |                                                                                |  0
 6 |                                                                                |  0
 7 |                                                                                |  0
 8 |                                                                                |  0
 9 |                                                                                |  0
10 |                                                                                |  0
11 |                                                                                |  0
12 |                                                                                |  0
13 |                                                                                |  0
14 |                                                                                |  0
15 |                                                                                |  0
16 |                                                                                |  0
17 |                                                                                |  0
18 |                                                                                |  0
19 |                                                                                |  0
20 |                                                                                |  0
21 |                                                                                |  0
22 |                                                                                |  0
23 |                                                                                |  0
24 | 1LIST   2RUN   3LOAD"  4SAVE"  5CONT  6,"LPT1 7TRON  8TROFF 9KEY    0SCREEN| 80
   +--------------------------------------------------------------------------------+
   +--------------------------------------------------------------------------------+
 0 |                                                                                |  0
 1 |                                                                                |  0
 2 |                                                                                |  0
 3 |                                                                                |  0
 4 |                                                                                |  0
 5 |                                                                                |  0
 6 |                                                                                |  0
 7 |                                                                                |  0
 8 |                                                                                |  0
 9 |                                                                                |  0
10 |                                                                                |  0
11 |                                                                                |  0
12 |                                                                                |  0
13 |                                                                                |  0
14 |                                                                                |  0
15 |                                                                                |  0
16 |                                                                                |  0
17 |                                                                                |  0
18 |                                                                                |  0
19 |                                                                                |  0
20 |                                                                                |  0
21 |                                                                                |  0
22 |                                                                                |  0
23 |                                                                                |  0
24 |                                                                                |  0
   +--------------------------------------------------------------------------------+
   +--------------------------------------------------------------------------------+
 0 |                                                                                |  0
 1 |                                                                                |  0
 2 |                                                                                |  0
 3 |                                                                                |  0
 4 |                                                                                |  0
 5 |                                                                                |  0
 6 |                                                                                |  0
 7 |                                                                                |  0
 8 |                                                                                |  0
 9 |                                                                                |  0
10 |                                                                                |  0
11 |                                                                                |  0
12 |                                                                                |  0
13 |                                                                                |  0
14 |                                                                                |  0
15 |                                                                                |  0
16 |                                                                                |  0
17 |                                                                                |  0
18 |                                                                                |  0
19 |                                                                                |  0
20 |                                                                                |  0
21 |                                                                                |  0
22 |                                                                                |  0
23 |                                                                                |  0
24 |                                                                                |  0
   +--------------------------------------------------------------------------------+
   +--------------------------------------------------------------------------------+
 0 |                                                                                |  0
 1 |                                                                                |  0
 2 |                                                                                |  0
 3 |                                                                                |  0
 4 |                                                                                |  0
 5 |                                                                                |  0
 6 |                                                                                |  0
 7 |                                                                                |  0
 8 |                                                                                |  0
 9 |                                                                                |  0
10 |                                                                                |  0
11 |                                                                                |  0
12 |                                                                                |  0
13 |                                                                                |  0
14 |                                                                                |  0
15 |                                                                                |  0
16 |                                                                                |  0
17 |                                                                                |  0
18 |                                                                                |  0
19 |                                                                                |  0
20 |                                                                                |  0
21 |                                                                                |  0
22 |                                                                                |  0
23 |                                                                                |  0
24 |                                                                                |  0
   +--------------------------------------------------------------------------------+
==== Scalars =======================================================================================

==== Arrays ========================================================================================

==== Strings =======================================================================================

==== Program Buffer ================================================================================
b'00' b'0000' (ENDS) b'' b''
==== Program =======================================================================================
==== Options =======================================================================================
[]

Notes

This happens whether or not there are any stored program lines (eg. typing 10 BEEP followed by AUTO . will still crash).

PC-BASIC version: Log from 2.0.5 (provided by Debian), reproduces on 2.0.7 (bb50fbfd 2023-04-02 15:17:45.995101) Operating system version: Log from Debian Sid (Linux-6.1.0-9-amd64-x86_64-with-glibc2.36), reproduces on Arch Linux (Linux-6.1.62-1-lts-x86_64-with-glibc2.38)

Marrin commented 9 months ago

I can reproduce this with PC-BASIC 2.0.6.