SmallBASIC icon indicating copy to clipboard operation
SmallBASIC copied to clipboard

0x10000000 error

Open jimswen opened this issue 8 years ago • 2 comments

Small Basic v12.8win fails with error whenever the basic source includes a literal equal to 2^28 in a binary-related format. That includes "0x10000000", "&h10000000", and their value-equivalents in octal (&o....) & binary (&b...). Seems to abort in the first scan, before execution starts. A range of values will cause this error: 0x10000000 to 0x10FFFFFF or something like that. The abort doesn't happen for 'val("0x10000000")', decimal literals, 0x20000000 / 2, 0x08000000 * 2, 2^28.

jimswen avatar Apr 01 '17 01:04 jimswen

Uploaded a zip packet of minimal abort-demo .bas files and screenshots of the results. min_demo.zip

Program is (with format variations) : a=0x10000000 b=0x0FFFFFFFF c=a-b : print c

b and c are always OK. a causes the error abort.

Error message is not entirely repeatable! Depending on [who-knows-what], the error message may give 1 string reapeatedly, or pick from 3 or 4 strings.
Once in a while it even fails to fail: the run completes without problem!
Alternative error messages include:

  • (EXPR} Syntax error,
  • (EXPR} Syntax error, (3)
  • (Unknown Error) IP 37=0x18 (or other 2-digit hex literal)
  • running normally, no abort or warning

I have built a tester.bas using TRY-CATCH within CHAINed string array program, launched from TRY-CATCH within chain-launching host program. They don't successfully catch this kind of error. Once in a while an error-provoking value returns from chained-prog to host without error.

I have been examining the github source bundle, downloaded as zip. Could Chris point me at a couple of files within it to investigate?

jimswen avatar Apr 19 '17 23:04 jimswen

Thanks for your report.

The windows version of SmallBASIC is built as a 32 bit program and the problem doesn't occur when SmallBASIC is built as a 64 bit version. The error is coming from the compiler (scan.c). It's probably an issue with overflowing the sign bit in some 32 bit int. If you are able to compile yourself, you could try changing the definition of var_int_t in sys.h to make the INT variant 64 bits. I'm guessing this would hurt performance.

I will investigate this further to see what can be included in the next release.

chrisws avatar May 05 '17 22:05 chrisws