Modulo by zero (Program Bug and Problems)

by Gordon, Wednesday, October 17, 2012, 14:36 (1656 days ago)

Hello,

SVN r526, modulo by zero (eg. "PRINT 10 % 0") crashes the interpreter with SIGFPE.

Core was generated by `./BASIC256'.
Program terminated with signal 8, Arithmetic exception.
#0 0x0000000000427677 in Interpreter::execByteCode (this=<value optimized out>) at Interpreter.cpp:1998
1998 stack.push(i2 % i1);
(gdb) bt full
#0 0x0000000000427677 in Interpreter::execByteCode (this=<value optimized out>) at Interpreter.cpp:1998
i1 = 0
i2 = <value optimized out>
one = 0x10d6db0
two = 0x10d6da0
#1 0x000000000042a590 in Interpreter::run (this=0x1120010) at Interpreter.cpp:723
No locals.
#2 0x00007f65c177e9f5 in QThreadPrivate::start (arg=0x1120010) at thread/qthread_unix.cpp:248
data = 0x128dcd0
#3 0x00007f65c14ee9ca in start_thread (arg=<value optimized out>) at pthread_create.c:300
__res = <value optimized out>
pd = 0x7f65b7547700
unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140074844190464, 5048750460226807362, 0, 0, 0, 140074844190464,
-5126313107674061246, -5126431910552492478}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0},
data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
not_first_call = <value optimized out>
robust = <value optimized out>
freesize = <value optimized out>
__PRETTY_FUNCTION__ = "start_thread"
#4 0x00007f65c0a9d16d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
No locals.
#5 0x0000000000000000 in ?? ()
No symbol table info available.

On a slightly related note, "10 / 0" returns "inf", which I'd wager should rather throw a runtime error instead.

Modulo by zero

by Jim ⌂ @, Russell, KY, Wednesday, October 17, 2012, 19:12 (1656 days ago) @ Gordon

I am adding a new trappable error for division by zero, mod, or integer division. Will look at other infinity conditions and should update the SVN today. This change will be in the next release.

Thanks for the help.

Modulo by zero

by Gordon, Wednesday, October 17, 2012, 21:51 (1656 days ago) @ Jim

Appears to be working fine, thank you.

RSS Feed of thread
powered by my little forum