robhagemans/pcbasic

Crash in `DRAW` statement on type mismatch in linked variable

arthurcazevedo opened this issue · 3 comments

Hello

Bug report

Problem

Trying to run a program with DRAW statement

Steps

  1. open pc-basic
  2. load the program with LOAD statement
  3. RUN

Program

05 SCREEN 2
07 S1$="60"
09 S2$="120"
10 D$ = "F=S1$; L=S2$; E=S1$; BD30 P1,2 BU30 E=S1$; L=S2$; F=S1$; BU30 P1,2"
20 DRAW "X" + VARPTR$(D$)

Crash log

PC-BASIC crash log

FATAL ERROR
version 2.0.6 [v2.0.6 08b78d7 2022-08-03 21:43:38.265384]
python 3.7.9 [32bit WindowsPE] True
platform Windows-10-10.0.22000
interface VideoSDL2, AudioSDL2
statement 20 DRAW "X" + VARPTR$(D$)

graphics.py:1007, draw_
graphics.py:1030, _draw
graphics.py:1068, _draw
mlparser.py:43, parse_number
AttributeError: 'String' object has no attribute 'to_int'

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:
    C:\Users\arthu\AppData\Roaming\pcbasic-2.0\crash-20220812-98iwn6bg.log
    Traceback (most recent call last):
    File "C:\pc-basic\pcbasic\guard.py", line 41, in protect
    File "C:\pc-basic\pcbasic\main.py", line 105, in run_session
    File "C:\pc-basic\pcbasic\basic\api.py", line 149, in interact
    File "C:\pc-basic\pcbasic\basic\implementation.py", line 313, in interact
    File "C:\pc-basic\pcbasic\basic\interpreter.py", line 124, in loop
    File "C:\pc-basic\pcbasic\basic\interpreter.py", line 114, in parse
    File "C:\pc-basic\pcbasic\basic\parser\statements.py", line 82, in parse_statement
    File "C:\pc-basic\pcbasic\basic\display\graphics.py", line 1007, in draw

    File "C:\pc-basic\pcbasic\basic\display\graphics.py", line 1030, in _draw
    File "C:\pc-basic\pcbasic\basic\display\graphics.py", line 1068, in _draw
    File "C:\pc-basic\pcbasic\basic\mlparser.py", line 43, in parse_number
    AttributeError: 'String' object has no attribute 'to_int'

==== Screen Pages ==================================================================================
+--------------------------------------------------------------------------------+
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 | 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
+--------------------------------------------------------------------------------+
+--------------------------------------------------------------------------------+
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
+--------------------------------------------------------------------------------+
+--------------------------------------------------------------------------------+
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 =======================================================================================
b'S1$': b'$'[b'027f12' b'60']
b'S2$': b'$'[b'038c12' b'120']
b'D$': b'$'[b'429b12' b'F=S1$; L=S2$; E=S1$; BD30 P1,2 BU30 E=S1$; L=S2$; F=S1$; BU30 P1,2']
==== Arrays ========================================================================================

==== Strings =======================================================================================
fdfa: bytearray(b'\x03\x07\x13')
fdf6: bytearray(b'X\x03\x07\x13')
==== Program Buffer ================================================================================
00 7612 (+008) 0500 [00005] c820130083120700533124e7223630220091120900533224e7223132302200df120a00442420e72022463d5331243b204c3d5332243b20453d5331243b20424433302050312c32204255333020453d5331243b204c3d5332243b20463d5331243b20425533302050312c322200f3121400fe922022582220e920da2428442429000000
00 8312 (+013) 0700 [00007] 533124e7223630220091120900533224e7223132302200df120a00442420e72022463d5331243b204c3d5332243b20453d5331243b20424433302050312c32204255333020453d5331243b204c3d5332243b20463d5331243b20425533302050312c322200f3121400fe922022582220e920da2428442429000000
00 9112 (+014) 0900 [00009] 533224e7223132302200df120a00442420e72022463d5331243b204c3d5332243b20453d5331243b20424433302050312c32204255333020453d5331243b204c3d5332243b20463d5331243b20425533302050312c322200f3121400fe922022582220e920da2428442429000000
00 df12 (+078) 0a00 [00010] 442420e72022463d5331243b204c3d5332243b20453d5331243b20424433302050312c32204255333020453d5331243b204c3d5332243b20463d5331243b20425533302050312c322200f3121400fe922022582220e920da2428442429000000
00 f312 (+020) 1400 [00020] fe922022582220e920da2428442429000000
00 0000 (ENDS)
==== Program =======================================================================================
5 SCREEN 2
7 S1$="60"
9 S2$="120"
10 D$ = "F=S1$; L=S2$; E=S1$; BD30 P1,2 BU30 E=S1$; L=S2$; F=S1$; BU30 P1,2"
20 DRAW "X" + VARPTR$(D$)
==== Options =======================================================================================
[

Notes

PC-BASIC version: as above
Operating system version: Windows 11 21H2

Thanks for reporting! This is indeed a bug as it should not crash.

Note (perhaps needless to say) that this program won't run even if the bug is fixed, as the variables linked in D$ should be numeric, not string. So the correct response from PC-BASIC would be Type mismatch in 20.

@robhagemans

Thank you for the fast response.

Change the variables to numeric works.

I'm using PC-Basic to learn the DRAW statement instead other basic interpreter in a DOS VM or DOS emulator to honor this project and help to find bugs. My intent is to implement something like DRAW in a modern environment, perhaps in a game engine.

And thank you to keep this memory of the good old times of PC history.

Fixed by bb2af3b