Suggestions-and-Issues icon indicating copy to clipboard operation
Suggestions-and-Issues copied to clipboard

[Bug]: [ALPHA] Division by zero crash with ISA immediates

Open altrag opened this issue 11 months ago • 0 comments

Discord Thread

https://discord.com/channels/828292123936948244/1330368647322931351

What happened?

I've created an instruction like this:

div %a:S16(immediate), %b:S16(immediate)
%c:S16 = %a / %b
cccccccc cccccccc

which immediately crashes if I write out something like div 9, 0, and prevents the level from being reloaded until I manually edit the .asm file (or I guess manually change the .isa). Obviously someone manually dividing by zero is not a normal situation (I ran across it just because I fat fingered the zero while doing some testing of the ISA syntax) but still shouldn't crash.

I also tried putting in my own protection:

safediv %a:S16(immediate), %b:S16(immediate)
%bits = 0 - popcount(%b)
!assert %bits >> 63 == 1 "Cannot divide by zero"
%c:S16 = %a / %b
cccccccc cccccccc

doesn't help - I guess it still tries to calculate the %c line no regardless of the assert.

Version

0.1357 Beta

What OSes are you seeing the problem on?

Windows

Relevant debug.log output, search next to the exectuable


Image

altrag avatar Jan 19 '25 02:01 altrag