FloatMathPlugin crash on 64-bit VM

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

FloatMathPlugin crash on 64-bit VM

Levente Uzonyi
 
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
Reply | Threaded
Open this post in threaded view
|

Re: FloatMathPlugin crash on 64-bit VM

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

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

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

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

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

Nicolas

2016-05-10 23:52 GMT+02:00 Levente Uzonyi <[hidden email]>:

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

Reply | Threaded
Open this post in threaded view
|

Re: FloatMathPlugin crash on 64-bit VM

Eliot Miranda-2
 
Hi Nicolas,

On Tue, May 10, 2016 at 11:19 PM, Nicolas Cellier <[hidden email]> wrote:
 
Hi Levente,
I have forgotten where do we load the FloatMathPluginTests from?

It's in VMMaker and VMMaker.oscog.
 

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 <[hidden email]>:

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