[Vm-dev] FloatMathPlugin crashes the VM if compiled with gcc optimization

Igor Stasenko siguctua at gmail.com
Sun Dec 26 21:19:32 UTC 2010


On 26 December 2010 21:57, Andreas Raab <andreas.raab at gmx.de> wrote:
>
> On 12/26/2010 8:40 PM, Igor Stasenko wrote:
>>
>> Note, that on unix and mac it defines -DNO_ISNAN
>> while on win32, it compiles with -O0 flag, which turns off all
>> optimizations.
>>
>> It would be good to know why optimization(s) causing crash, and how we
>> could fix that in code,
>>  because i'm not in favor having VM  which stability depends on
>> compiler peculiarities.
>
> Because fdlibm aliases integer pointers with floating point values.
> Compilers generally don't assume that, i.e.,
>
>        double foo = 1.0;
> #ifdef BIGENDIAN
>        unsigned int *highWord = (unsigned int*)&foo;
> #else
>        unsigned int *highWord = ((unsigned int*)&foo)++;
> #endif
>        *highWord |= 0x8000000;
>
> might change the sign of foo and that it would invalidate a prior value in
> an fpu register. But fdlibm does this kind of stuff *all the time*.
>

omg..

low level C code which pretending to know how to do it 'right' +
C compiler , who also knowing how to do it 'right' ===>> mess in result :)

> Cheers,
>  - andreas
>



-- 
Best regards,
Igor Stasenko AKA sig.


More information about the Vm-dev mailing list