<div dir="ltr"><div dir="ltr">Hi all,<div><br></div><div>I've tested using the volatile keyword in all variables in the function and the problem is still there.</div><div>So while I get some time to look at the asm outputs I've issued a PR with the discussed solution in here: <a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/353" target="_blank">https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/353</a></div><div><br></div><div>@Nicolas, I was able to compile and debug win64 almost out of the box. However, I could not make the visual studio code debugging extension work for the 32bit version.<br></div><div>Where you compiling on clang with just the makefiles or you have used visual studio for that?</div><div>Also, could you share your visual studio project files? I'd like to try debugging with it :)</div><div><br></div><div>Tx all,</div><div>Guille</div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Jan 16, 2019 at 10:18 AM Nicolas Cellier <<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <div dir="ltr"><div>And if it fails with new versions of gcc, it would also be intersting to test with clang.</div><div>For Win64 I had to use clang...<br></div></div><br><div class="gmail_quote"><div dir="ltr">Le mer. 16 janv. 2019 à 09:59, Guillermo Polito <<a href="mailto:guillermopolito@gmail.com" target="_blank">guillermopolito@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <div dir="ltr"><div dir="ltr">Hi Eliot!<div><br></div><div>Thanks for the quick answer :)</div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jan 15, 2019 at 6:04 PM Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <div dir="ltr"><div>Hi Guille, Hi Pablo,</div><div><br></div><div>    I misspoke...</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jan 15, 2019 at 9:00 AM Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Guille,</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jan 15, 2019 at 8:45 AM Guillermo Polito <<a href="mailto:guillermopolito@gmail.com" target="_blank">guillermopolito@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <div dir="ltr"><div dir="ltr">Hi all,<div dir="ltr" class="gmail-m_-6931072169335668202gmail-m_-3973250878818758660gmail-m_6703484919829624075gmail-m_3890360071402162828gmail-m_4053899900125789182gmail-m_7145681753933559026gmail-m_-979907575056022412gmail_signature"><div dir="ltr"><div></div></div></div><div><br></div><div>With Pablo we have been tracking a bug on win32 that produces a segmentation fault on callback return. We can reproduce it 100% certainly when running the Alien qsort example both in latest pharo and squeak versions.</div><div><br></div><div>After some debugging, it would seem that the thunkEntry function is over-optimized in 32 bits, corrupting the (C) stack. This was particularly boring because compiling the VM in debug mode was taking the bug away :-). We have cornered the bug and checked that callbacks do work ok if we disable optimizations just for the thunkEntry function like this:</div><br>long<br>__attribute__((optimize("O0"))) thunkEntry(void *thunkp, sqIntptr_t *stackp) </div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div><br></div><div>The thing is that latest mingw which we use for compiling the windows VM even in travis, now comes with gcc 7.4.0 which has a lot more of optimizations than before. Just having O1 also produces the same error.</div><div><br></div><div>We have tried disabling some particular optimizations like fno-combine-stack-adjustments but with no result so far.</div><div><br></div><div>The strange thing is that other callbacks like the ones coming from libgit work ok.</div><div><br></div><div>Has somebody taken a look into this too?</div><div>How would you suggest that we move on with this?</div></div></div></blockquote><div><br></div><div>Before adding the pragma to the source also look at whether using the volatile keyword on variables in thunkProcess fixes the issue; for example </div><div><br></div><div>    volatile VMCallbackContext vmcc;</div><div>    volatile VMCallbackContext *previousCallbackContext;</div><div>    volatile int flags, returnType;</div></div></div></div></div></div></div></div></blockquote></div></div></blockquote><div><br></div><div>Ok I'm trying this now. At least I can launch compilation and do something else [<a href="https://xkcd.com/303/" target="_blank">https://xkcd.com/303/</a>] while it compiles :)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div><br></div><div>.  The other thing to do is to generate the machine code for thinkProcess with gcc 7.x and an older version that does not crash and compare to try and find out what specific optimization is causing the crash.</div></div></div></div></div></div></div></div></blockquote><div><br></div><div>I meant generate the assembly with -S, e.g. -O1 -S.</div></div></div></blockquote><div><br></div><div>Sure, this is what we understood ^^.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div>You can also compare _O0 -S with -O1 -S for gcc 7.x, and generate -O1 -S with and without the volatile keyword and see what differences that makes.</div></div></div></blockquote><div><br></div><div>I'll do this this afternoon If I have some time...</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"><div dir="ltr"><div class="gmail_quote"><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"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div>Finally, if you do find you have to use the pragma, please write the fix as<br></div><div><br></div><div><span style="color:rgb(0,0,0)">long </span><span style="color:rgb(0,0,0)">__attribute__((optimize("O0"))</span><span style="color:rgb(0,0,0)">)</span></div><div><span style="color:rgb(0,0,0)">thunkEntry(void *thunkp, sqIntptr_t *stackp)</span><br></div><div><span style="color:rgb(0,0,0)"><br></span></div><div><span style="color:rgb(0,0,0)">to keep the definition starting on a new line, which helps when using command-line tools to look for definitions outside of an </span><font color="#000000"><span>ide.</span></font></div></div></div></div></div></div></div></div></blockquote></div></div></blockquote><div><br></div><div>Sure! no problem!</div><div><br></div><div>Tx Again!</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>From our side, we think that using a pragma to disable optimizations for thunkEntry in the case of win32 looks okeyish at least to make the bug go away.</div></div></div></blockquote><div><br></div><div>Yes, but I expect it is actually that the volatile keyword has not been used (a mistake of mine).  Here's a relevant stack overflow answer:</div><div><a href="https://stackoverflow.com/questions/7996825/why-volatile-works-for-setjmp-longjmp" target="_blank">https://stackoverflow.com/questions/7996825/why-volatile-works-for-setjmp-longjmp </a></div><div><br></div><div>And if volatile does fix the issue, please apply it to the other thinkEntry implementations.</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"><div dir="ltr"><div dir="ltr"><div>Cheers,<br></div><div>Guille & Pablo</div></div></div>
</blockquote></div><br clear="all"><div>Cheers!</div></div></div></div></div></div></div></blockquote><div> </div></div><div dir="ltr" class="gmail-m_-6931072169335668202gmail-m_-3973250878818758660gmail-m_6703484919829624075gmail-m_3890360071402162828gmail-m_4053899900125789182gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_-6931072169335668202gmail-m_-3973250878818758660gmail-m_6703484919829624075gmail-m_3890360071402162828gmail_signature"><div dir="ltr"><div><div dir="ltr"><table style="border-collapse:collapse" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width:86px;height:84px;border-style:solid;border-width:0px 1px 0px 0px;border-color:transparent rgb(0,0,0) transparent transparent;padding:4px" valign="top">
<p style="margin:0px;min-height:14px"><font style="font-stretch:normal;font-size:10px;line-height:normal;font-family:Helvetica;color:rgb(0,0,0)" face="Helvetica" color="#000000"> </font><span style="font-family:Helvetica;font-size:10px"> </span><span style="font-family:Helvetica;font-size:10px"> </span><img src="https://www.cristal.univ-lille.fr//videos/presentation.jpg" width="200" height="112"><img src="https://intranet.cnrs.fr/Cnrs_pratique/communiquer/guides/PublishingImages/CNRS-filaire-Bichro-CMJN.jpg" alt="" style="font-size: 12.8px; margin: 5px;" width="96" height="96"></p>















</td><td style="width:378px;height:84px;border-style:solid;border-width:0px 0px 0px 1px;border-color:transparent transparent transparent rgb(0,0,0);padding:4px" valign="top"><p style="margin:0px"><font style="font-stretch:normal;font-size:10px;line-height:normal;font-family:Helvetica;color:rgb(0,0,0)" face="Helvetica" color="#000000">Guille Polito</font></p><p style="margin:0px"><span style="color:rgb(0,0,0);font-family:Helvetica;font-size:10px">Research Engineer</span></p><p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Helvetica;color:rgb(0,0,0);min-height:10px"><font></font></p><p style="margin:0px"><font style="font-stretch:normal;font-size:10px;line-height:normal;font-family:Helvetica;color:rgb(0,0,0)" face="Helvetica" color="#000000">Centre de Recherche en Informatique, Signal et Automatique de Lille</font></p><p style="margin:0px"><font style="font-stretch:normal;font-size:10px;line-height:normal;font-family:Helvetica;color:rgb(0,0,0)" face="Helvetica" color="#000000">CRIStAL - UMR 9189</font></p>
<p style="margin:0px"><font style="font-stretch:normal;font-size:10px;line-height:normal;font-family:Helvetica;color:rgb(0,0,0)" face="Helvetica" color="#000000">French National Center for Scientific Research - <font><u><a href="http://www.cnrs.fr" target="_blank">http://www.cnrs.fr</a></u></font></font></p><p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Helvetica;color:rgb(0,0,0);min-height:10px"><br></p>
<p style="margin:0px"><font style="font-stretch:normal;font-size:10px;line-height:normal;font-family:Helvetica;color:rgb(0,0,0)" face="Helvetica" color="#000000"><b>Web:</b> <a href="http://guillep.github.io" target="_blank"><font><u>http://guillep.github.io</u></font></a></font></p>
<p style="margin:0px"><font style="font-stretch:normal;font-size:10px;line-height:normal;font-family:Helvetica;color:rgb(0,0,0)" face="Helvetica" color="#000000"><b>Phone: </b>+33 06 52 70 66 13</font></p>
</td>
</tr>
</tbody>
</table></div></div></div></div></div>
</blockquote></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_-6931072169335668202gmail-m_-3973250878818758660gmail_signature"><div dir="ltr"><div><div dir="ltr"><table cellspacing="0" cellpadding="0" style="border-collapse:collapse">
<tbody>
<tr>
<td valign="top" style="width:86px;height:84px;border-style:solid;border-width:0px 1px 0px 0px;border-color:transparent rgb(0,0,0) transparent transparent;padding:4px">
<p style="margin:0px;min-height:14px"><font face="Helvetica" color="#000000" style="font-stretch:normal;font-size:10px;line-height:normal;font-family:Helvetica;color:rgb(0,0,0)"> </font><span style="font-family:Helvetica;font-size:10px"> </span><span style="font-family:Helvetica;font-size:10px"> </span><img src="https://www.cristal.univ-lille.fr//videos/presentation.jpg" width="200" height="112"><img src="https://intranet.cnrs.fr/Cnrs_pratique/communiquer/guides/PublishingImages/CNRS-filaire-Bichro-CMJN.jpg" alt="" style="font-size: 12.8px; margin: 5px;" width="96" height="96"></p>















</td><td valign="top" style="width:378px;height:84px;border-style:solid;border-width:0px 0px 0px 1px;border-color:transparent transparent transparent rgb(0,0,0);padding:4px"><p style="margin:0px"><font face="Helvetica" color="#000000" style="font-stretch:normal;font-size:10px;line-height:normal;font-family:Helvetica;color:rgb(0,0,0)">Guille Polito</font></p><p style="margin:0px"><span style="color:rgb(0,0,0);font-family:Helvetica;font-size:10px">Research Engineer</span></p><p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Helvetica;color:rgb(0,0,0);min-height:10px"><font></font></p><p style="margin:0px"><font face="Helvetica" color="#000000" style="font-stretch:normal;font-size:10px;line-height:normal;font-family:Helvetica;color:rgb(0,0,0)">Centre de Recherche en Informatique, Signal et Automatique de Lille</font></p><p style="margin:0px"><font face="Helvetica" color="#000000" style="font-stretch:normal;font-size:10px;line-height:normal;font-family:Helvetica;color:rgb(0,0,0)">CRIStAL - UMR 9189</font></p>
<p style="margin:0px"><font face="Helvetica" color="#000000" style="font-stretch:normal;font-size:10px;line-height:normal;font-family:Helvetica;color:rgb(0,0,0)">French National Center for Scientific Research - <font><u><a href="http://www.cnrs.fr" target="_blank">http://www.cnrs.fr</a></u></font></font></p><p style="margin:0px;font-stretch:normal;font-size:10px;line-height:normal;font-family:Helvetica;color:rgb(0,0,0);min-height:10px"><br></p>
<p style="margin:0px"><font face="Helvetica" color="#000000" style="font-stretch:normal;font-size:10px;line-height:normal;font-family:Helvetica;color:rgb(0,0,0)"><b>Web:</b> <a href="http://guillep.github.io" target="_blank"><font><u>http://guillep.github.io</u></font></a></font></p>
<p style="margin:0px"><font face="Helvetica" color="#000000" style="font-stretch:normal;font-size:10px;line-height:normal;font-family:Helvetica;color:rgb(0,0,0)"><b>Phone: </b>+33 06 52 70 66 13</font></p>
</td>
</tr>
</tbody>
</table></div></div></div></div>