davidgiven / ack

The Amsterdam Compiler Kit
http://tack.sf.net
Other
421 stars 59 forks source link

[bug] integer division overflow is not handled in the interpreter and crashes it #192

Closed ccodere closed 5 years ago

ccodere commented 5 years ago

The em interpreter does not properly handle signed integer division overflow. For example, running the following em code with a word size of 2 currently gives me a floating point exception and stops the interpreter:

loc -32768
loc -1
dvi EM_WSIZE

The issue is in do_intar.c in the private function dvi() there is no check for this condition. As stated in the SEI CMU web site, when the dividend is equal to the minimum (negative) value for the signed integer type and the divisor is equal to −1 this leads to overflow.

I will fix this in my next commit.