[Vm-dev] FloatMathPlugin crash on 64-bit VM

Eliot Miranda eliot.miranda at gmail.com
Wed May 11 17:44:14 UTC 2016


Hi Nicolas,

On Tue, May 10, 2016 at 11:19 PM, Nicolas Cellier <
nicolas.cellier.aka.nice at gmail.com> wrote:

>
> Hi Levente,
> I have forgotten where do we load the FloatMathPluginTests from?
>

It's in VMMaker and VMMaker.oscog.


> Could it be related to:
>
> http://lists.squeakfoundation.org/pipermail/vm-dev/2010-December/006302.html
>

It could be, but the issue is 64-bits only, and the optimised version seems
to work fine on 32-bits except for three functions, see
platforms//win32/plugins/FloatMathPlugin/Makefile:

# Special OFLAGS for some files
k_tan.o: k_tan.c
    $(MAKE) -f ../../Makefile.plugin OFLAGS="-O0" $*.o

acos.o: acos.c
    $(MAKE) -f ../../Makefile.plugin OFLAGS="-O0" $*.o

tanh.o: tanh.c
    $(MAKE) -f ../../Makefile.plugin OFLAGS="-O0" $*.o


> fdlibm uses pointer aliasing, so special compiler flags are mandatory on
> modern C compiler to make it work
>
> http://lists.squeakfoundation.org/pipermail/squeak-dev/2013-February/168890.html
>

Right.  So I will add the equivalent if it exists in clang.

Once I proposed simple changes to "fix" the library
>
> http://lists.squeakfoundation.org/pipermail/vm-dev/2010-December/006350.html
>

I *think* that none of the aliasing would be required if the code were
rewritten to use a 64-bit integer datatype (long long) to hold doubles.
Looks to me that everything was written before long long; the tables of
64-bit floating-point constants are split into 32-bit halves, etc.  But
it's a lot of work to rewrite.  I wonder whether there are other open
source communities interested in collaborating on this.  Also, how much
work would it be to write an equivalent library using Slang?

Anyone know if a company like Google or Facebook would have the resources
to fund a replacement?  It looks to be less than a months work by someone
competent, perhaps a week.  Also are there any tests?  I've not been able
to find them.  It's incredible that much of the industry is replying on an
old and inefficient version of such critical functionality.

Note that 64bits also require -D__LITTLE_ENDIAN flag on 64bits
>
> http://lists.squeakfoundation.org/pipermail/vm-dev/2010-December/006352.html
>


IMO, better would be to include sqConfg.h.  A "clean" way to do this is to
rename fdlibm.h to e.g. realfdlibm.h and have a new fdlibm.h that includes
sqConfig.h, defines __LITTLE_ENDIAN in terms of VMBIGENDIAN and then
includes realfdlibm.h


Nicolas
>



2016-05-10 23:52 GMT+02:00 Levente Uzonyi <leves at caesar.elte.hu>:
>
>>
>> Hi All,
>>
>> Evaluating any of the three lines below will make the VM (64-bit 3684 on
>> linux) crash:
>>
>> FloatMathPluginTests basicNew cos: -7.384669756559583e-194
>> FloatMathPluginTests basicNew sin: -7.384669756559583e-194
>> FloatMathPluginTests basicNew tan: -7.384669756559583e-194
>>
>> There's no crash with the 32-bit VM.
>>
>> Levente
>>
>
>
>


-- 
_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20160511/0e7e6c6d/attachment-0001.htm


More information about the Vm-dev mailing list