<div dir="ltr"><div><div>I've reproduced the crash in squeak.stack.spur Win32 with latest vm sources (SHA aa11221d9ebb5d60b0b88a2f1f8e27f19909d718)<br>This crashing VM is compiled with gcc via ./mvm -f<br><br>The Win64 version passes correctly. But it is compiled with clang by default.<br>The Win32 compiled with clang also passes correctly for me.<br><br>The test is translated in pure Alien for purpose of testing on Squeak 5.0 (see instructions below).<br><br>--------------------------------------------------------------<br><br></div><div>from cygwin (or cygwin64) shell:<br><br>$ i686-w64-mingw32-gcc --version<br>i686-w64-mingw32-gcc (GCC) 5.4.0<br>Copyright (C) 2015 Free Software Foundation, Inc.<br>This is free software; see the source for copying conditions.  There is NO<br>warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.<br><br>$ i686-w64-mingw32-clang --version<br>clang version 3.8.1 (tags/RELEASE_381/final)<br>Target: i686-w64-windows-gnu<br>Thread model: posix<br>InstalledDir: /usr/bin<br><br>$ x86_64-w64-mingw32-clang --version<br>clang version 3.8.1 (tags/RELEASE_381/final)<br>Target: x86_64-w64-windows-gnu<br>Thread model: posix<br>InstalledDir: /usr/bin<br><br>--------------------------------------------------------------<br><br><div>$ cd build.win32x86/squeak.stack.<wbr>spur<br></div><div>$ ./mvm -f -- CC=i686-w64-mingw32-clang<br><br></div><div>or for 64 bits:<br><br><div>$ cd build.win64x64/squeak.stack.<wbr>spur<br></div>$ ./mvm -f<br><br>--------------------------------------------------------------<br><br></div><div>$ cat >test.c << END<br>#include "stdint.h"<br>int8_t test(int8_t(*function)(int8_t)<wbr>, int8_t value) {<br>       return function(value);<br>    }<br></div>END<br><br>$ i686-w64-mingw32-clang -c test.c<br>$ i686-w64-mingw32-clang -shared -o build/vm/test.dll test.o<br>$ build/vm/Squeak.exe<br><br>--------------------------------------------------------------<br><br></div><div>then from Smalltalk image with Alien properly loaded (Alien-eem.39):<br></div><div><br></div>Callback>>int8RetInt8: callbackContext regs: regsAlien<br>    <signature: #(int8 (*)(int8))><br>    ^callbackContext wordResult:<br>        (block value: (regsAlien signedCharAt: 1) asInteger)<br><br></div><div>(for now, above method must be compiled in each Callback subclass since we do not ask Pragma to scan superclass for signatures)<br></div><div><br>TestCase subclass: #AlienCallbackSunit<br>    instanceVariableNames: ''<br>    classVariableNames: ''<br>    poolDictionaries: ''<br>    category: 'Alien-CoreTest'<br><br>AlienCallbackSunit>><wbr>createCallback<br>       ^Callback <br>          signature: #(int8 (*)(int8))<br>          block: [ :value | value ]<br><br>AlienCallbackSunit>>primCall: aCallback int8: aNumber<br>       | r |<br>    (Alien lookup: 'test'  inLibrary: 'test.dll')<br>        primFFICallResult: (r := Alien new: 1)<br>        with: aCallback thunk<br>        with: aNumber.<br>    ^(r signedCharAt: 1) asInteger<br><br>AlienCallbackSunit>>test<br>      self <br>        assert: (self primCall: self createCallback int8: 0)<br>        equals: 0<br><br></div>AlienCallbackSunit new test.<br><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-01-14 2:53 GMT+01:00 Eliot Miranda <span dir="ltr"><<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>Hi Aliaksei,</div><div><div class="h5"><div id="m_-2233568840261244605AppleMailSignature"><br></div><div>On Jan 13, 2017, at 10:27 AM, Aliaksei Syrel <<a href="mailto:alex.syrel@gmail.com" target="_blank">alex.syrel@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div>Hi</div><div><br></div><div>The following code crashes windows spur32 VM without crash.dmp:</div><div>(crashes not only in case of int8, but ulong, int16/32 and so on...)</div><div><br></div><div>Callback instantiation: </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font face="monospace, monospace">createCallback<br></font><font face="monospace, monospace">   ^ FFICallback <br></font><font face="monospace, monospace"><span style="white-space:pre-wrap">      </span>signature: #(int8 (int8))<br></font><font face="monospace, monospace"><span style="white-space:pre-wrap">      </span>block: [ :value | value ]</font></blockquote><div><br></div><div>C function:</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font face="monospace, monospace">int8_t test(int8_t(*function)(int8_t)<wbr>, int8_t value) {<br></font><font face="monospace, monospace">   return function(value);<br></font><font face="monospace, monospace">}</font></blockquote><div><br></div><div>FFI call:</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font face="monospace, monospace">primCall: aCallback int8: aNumber<br></font><font face="monospace, monospace">   ^ self ffiCall: #(int8 test(FFICallback aCallback, int8 aNumber))</font></blockquote><div><br></div><div>Test case:</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font face="monospace, monospace">test<br></font><font face="monospace, monospace">  self <br></font><font face="monospace, monospace">    assert: (self primCall: self createCallback int8: 0)<br></font><font face="monospace, monospace">    equals: 0</font></blockquote><div><br></div><div><br></div><div>Windows 10.</div><div>VM from today:</div><div><a href="http://files.pharo.org/vm/pharo-spur32/win/pharo-win-i386-201701130756-83c0ef1.zip" target="_blank">http://files.pharo.org/vm/<wbr>pharo-spur32/win/pharo-win-<wbr>i386-201701130756-83c0ef1.zip</a></div><div>Image 60343:</div><div><a href="http://files.pharo.org/image/60/60343.zip" target="_blank">http://files.pharo.org/image/<wbr>60/60343.zip</a><br></div><div><br></div><div>P.S. what is the best place to report FFI / Alien issues?</div></div></div></blockquote><div><br></div></div></div>vm-dev<span class=""><div><br><blockquote type="cite"><div><div dir="ltr"><div>P.P.S Iceberg works</div><br clear="all"><div><div class="m_-2233568840261244605gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Cheers,<div>Alex</div></div></div></div></div></div></div></div>
</div>
</div></blockquote></div></span></div></blockquote></div><br></div>