Hi Nicholas,<div><br></div><div>&nbsp;&nbsp; &nbsp;the x87 FPU (embedded in all modern x86&#39;s and used by default to pass floating point arguments in ABI calls) is a stack of only 8 registers.</div><div><br></div><div>Imagine what happens if you attempt an FFI call that parse, say, 4 of its floating-point arguments before hitting an invalid parameter. &nbsp;Likely the FFI marshalling machinery will leave 4 items on the x87&#39;s stack and forget to clean them up.</div>
<div><br></div><div>Imagine what happens if you call some broken code that doesn&#39;t leave the x87 register stack empty.</div><div><br></div><div>In either of these cases the next time you try and make a call and load items onto the x87&#39;s stack it&#39;ll quite possibly overflow.</div>
<div><br></div><div>So.... the FFI marshalling machinery really needs to reset the FPU&#39;s stack pointer to zero both before and after making a call. &nbsp;I don&#39;t know if the FFI does this but chances are it doesn&#39;t.</div>
<div><br></div><div>In my time VisualWorks suffered problems like this, including its machine code floating point primitives not zeroing the x87 stack pointer on primitive fail. &nbsp;Now it does an fninit (the relevant instruction to intialize the x87 FPU) in relevant places.</div>
<div><br></div><div>Cheers</div><div>Eliot</div><div><br><div class="gmail_quote">On Tue, Jan 13, 2009 at 11:12 AM, nicolas cellier <span dir="ltr">&lt;<a href="mailto:ncellier@ifrance.com">ncellier@ifrance.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">nicolas cellier a écrit :<div><div></div><div class="Wj3C7c"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Apologies for the cryptic subject...<br>
<br>
I have some news about <a href="http://bugs.squeak.org/view.php?id=3929" target="_blank">http://bugs.squeak.org/view.php?id=3929</a><br>
I detected with gdb that the example I provided triggers a FPU stack overflow. When this occurs, a qNan is placed on FPU stack top.<br>
<br>
Thus, though ffiFloatReturnValue == 0.0, testing in Smalltalk (self myFFICall = 0.0) will result in 0.0==Nan due to stack overflow.<br>
primitive which execute special send #= will incorrectly return false...<br>
<br>
Don&#39;t tell me to not use = on Floats, this is not the problem, you can replace the test with (self myFFICall &lt; 1.0), you will get (0.0&lt;qNan) -&gt; false all the same.<br>
<br>
At this point, I see two possibilities:<br>
- either I totally messed up with calling conventions<br>
- or the FFI glue ffiCallAddressOf is broken<br>
($VM/Squeak-3.10-1/platforms/unix/plugins/SqueakFFIPrims/x86-sysv-asm)<br>
<br>
I have no knowledge about IA-32 and don&#39;t wish to learn further, using gdb at instruction level was already painfull enough for me.<br>
Can somebody aware of x86 and calling convention check my guess?<br>
<br>
Nicolas<br>
<br>
<br>
</blockquote>
<br></div></div>
Any one that can provide light on this subject?<br>
Or just get a contact with Ian Piumarta?<br>
<br>
I feel a bit alone<br><font color="#888888">
<br>
Nicolas<br>
<br>
<br>
</font></blockquote></div><br></div>