[fpc-devel] Exception problems in FPC 3.0.0

Yury Sidorov jura at cp-lab.com
Mon Oct 26 22:02:01 CET 2015


On 10/26/2015 9:38 PM, Sergio Flores wrote:
> Hi guys, congrats for the 3.0 release!
>
> However after upgrading FPC, my Android game now crashes with division
> by zero exceptions (it happens always in the same place).
>
> I changed nothing in the code, only the compiler changed from a 2.7.x to
> 3.0.0 (cross compiler windows to Arm binary version obtained from the
> link that was distributed in the mailing list last week).
> If I revert to using the old compiler, no exceptions happen.
>
> Note that I have this line in one of my units:
>
> Initialization
> SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow,
> exUnderflow, exPrecision]);
> End.
>
> I masking all of those stuff because it is a requisite for OpenGL graphics.
>
> Looking at the breaking changes section of the wiki, I dont see anything
> related. Anyone has an idea of what changed that could cause this or at
> least how I can debug it?

I suppose your issue is caused by the following:
The 3.0 release arm-android cross compiler is bundled with units 
compiled with the soft float FPU emulation.
In such case SetExceptionMask() masks only softfloat exceptions. And if 
the OpenGL library uses true FPU code, its exceptions are not masked.

You can:
- build FPC units from sources with FPU support.

or

- use the following code to mask FPU exceptions:

procedure VFP_SetCW(cw : dword); nostackframe; assembler;
   asm
     fmxr fpscr,r0
   end;

...

VFP_SetCW($1F00);  // Mask all FPU exceptions

...

Yury Sidorov.



More information about the fpc-devel mailing list