Consistent crash when starting very long program (Program Bug and Problems)

by Frederick Weld, Sunday, September 22, 2013, 14:42 (1312 days ago)

Hi,

I have been implementing a very large project in basic256, and now that the source file has grown beyond 180kb, basic256 crashes whenever I run the program.

More details:
- Crash observed for 0.9.9.68 in the same manner on both Windows (installed from Win32-installer) and Ubuntu (locally compiled)
- On 0.9.6.66, there is no crash but an erroneous error message "syntax error in line 4544" (that line is completely blank)

As you almost certainly need my kbs file in order to identify the issue, please indicate how I can send it (no attachment allowed in this post - besides, I wouldn't want to publish the kbs anyway).

Thanks,
Frederick

Consistent crash when starting very long program

by UglyMike ⌂ @, Brussels, Monday, September 23, 2013, 10:58 (1311 days ago) @ Frederick Weld

I know what you are talking about. Every now and then, I get random syntax errors on 'normal' code lines when starting my 188K Basic Paint program (and especially the updated version I'm working on (200K))
It is not consistent however. Once it happens, I have to start it 2-3 times (sometimes after a Basic256 restart) and then it loads. If been trying to provoke it here now on the 9.9.64 Portable edition and of course, the error doesn't happen. Like I said, not really consistent... I do agree however that there is an issue (but I doubt that many people will hit this constraint....)
If interested, you can find my program on www.uglymike.net under "Basic-256 Demo Programs".

Consistent crash when starting very long program

by Frederick Weld @, Monday, September 23, 2013, 12:06 (1311 days ago) @ UglyMike

Hi Mike,

apparently, my situation is not as lucky as yours for my 180kb kbs file:
- 0.9.9.68: basic256 crashes 10 times out of 10 (both windows/linux).
- 0.9.6.66: basic256 reports an empty line syntax error 10 times out of 10 (linux).

The only means of averting the crash (0.9.9.68) or the error (0.9.6.66) is to reduce the program size (fewer lines or shorter variable names).

As a remark, I began running into minor issues (minor meaning inconsistent as for you) from the filesize of 150kb on.

To the developers:
As this is clearly a parsing/validation issue, its root cause is either a bug in LEX/YACC (unlikely?) or within their configuration (grammar, callback?, etc).

Since my kbs project is now completely stalled, I would really appreciate if you could have a look at it.

Thanks in advance,
Frederick

Consistent crash when starting very long program

by UglyMike ⌂ @, Brussels, Monday, September 23, 2013, 13:23 (1311 days ago) @ Frederick Weld

Apparently not the first time this was stumbled upon....

http://forum.basic256.org/index.php?id=299

Strange, cause by copying/pasting sets of subroutines multiple times and also copying/pasting while loops in the main program, I can go to 10000 lines/400K without any issue. Even adding 600 long-named variables in the 10000 line program does not give issues here. I doubt that the LEX/YACC parser can identify the 'dummy' code & vars. Maybe it is not so much the amount of code but the combination of size and other resource requirements that is the issue (stack space, variables, strings, arrays, memory space due to too many/too great constructs or program size etc.)
No idea really.... We'll have to wait for Jim...
BTW, I'm running this on a Win7 at work (hence the Portable version....)

Consistent crash when starting very long program

by Frederick Weld @, Wednesday, September 25, 2013, 05:42 (1309 days ago) @ UglyMike

Some additional insights when using 0.9.9.69 (current svn trunk):

- Program still crashes upon run (as for 0.9.9.68).

- This also applies even if the program is partitioned into smaller parts and INCLUDE is used to merge them.

----* This should not come as a surprise to the developers since INCLUDEs are merged into the main program in the LEX step.

- Given this, the issue is almost certainly within the YACC configuration.

----* I've seen some hard constants / restrictions there (2000 vars, 1000 ifs)

----* But I haven't found any restriction that explains the symptoms (removing sufficient empty lines / comments leads to no crash)


--Frederick

Consistent crash when starting very long program

by Frederick Weld @, Thursday, September 26, 2013, 07:45 (1308 days ago) @ Frederick Weld

----* I've seen some hard constants / restrictions there (2000 vars, 1000 ifs)

----* But I haven't found any restriction that explains the symptoms (removing sufficient empty lines / comments leads to no crash)

By having edited the .y file, I can now confirm that these restrictions are not the cause of the crash:

* The same symptom appears, even if setting aforementioned constants to high numbers and even setting the initial alloc to very high levels (>>1024).

* The crash is due to "segmentation fault" (that is only visible when starting basic256 from the command line). I presume that some pointer value is corrupted. But based on the code, I cannot identify how this could happen.

--Frederick

Consistent crash when starting very long program

by Frederick Weld @, Tuesday, October 01, 2013, 20:57 (1303 days ago) @ Frederick Weld

* The crash is due to "segmentation fault"

Some more details about the erroneous memory access after some self-made tracing in the Interpreter.cpp:

* basicParse returns corrupted byte code: in my case, after a OP_GOSUB, there is a negative integer which is used as a negative labeltable offset, which leads of course to a crash

* The currentLine pointed to does not contain any gosub statement (the nearest is about 10 lines away)

*** This means that the gosub OP code could also be corrupted

--Frederick

Consistent crash when starting very long program

by Jim ⌂ @, Russell, KY, Thursday, October 17, 2013, 02:42 (1287 days ago) @ Frederick Weld

http://forum.basic256.org/index.php?id=1211

Looks like Frederick found this and I just uploaded the fix to SVN.

Jim

RSS Feed of thread
powered by my little forum