<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">hah! <div class="">you know what is the sad part of this? I wrote that message… it was for the future me, but I forget to check our flags :P</div><div class="">I lost 2.5 days then + 2 days now. </div><div class=""><br class=""></div><div class="">this fixes the problem with Windows crashes (yay!) but not the problem with callbacks (booo!)… any idea in that area?</div><div class=""><br class=""></div><div class="">cheers, </div><div class="">Esteban</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 29 Nov 2016, at 17:30, Ronie Salgado <<a href="mailto:roniesalg@gmail.com" class="">roniesalg@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">The last week I was having this exactly same crash in the MinimalisticHeadless branch, with both MinGW and with Visual Studio. I managed to get the VM working with MinGW (not yet with MSVC) by using the following defines,which I copied from the old Pharo CMake scripts:<br class=""><br class="">                -DSTACK_ALIGN_BYTES=16
      
      
                        -DALLOCA_LIES_SO_USE_GETSP=0<br class=""><br class="">In the pharo-vm, the CogFamilyWindowsConfig >> #commonCompilerFlags method starts with the following comment:<br class="">commonCompilerFlags<br class="">    "omit -ggdb2 to prevent generating debug info"<br class="">    "Some flags explanation: <br class="">    <br class="">    STACK_ALIGN_BYTES=16 is needed in mingw and FFI (and I suppose on other modules too).<br class="">    DALLOCA_LIES_SO_USE_GETSP=0 Some compilers return the stack address+4 on alloca function, <br class="">    then FFI module needs to adjust that. It is NOT the case of mingw.<br class="">    For more information see this thread: <a href="http://forum.world.st/There-are-something-fishy-with-FFI-plugin-td4584226.html" class="">http://forum.world.st/There-are-something-fishy-with-FFI-plugin-td4584226.html</a><br class="">    "<br class=""><br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">2016-11-29 9:32 GMT-03:00 Esteban Lorenzano <span dir="ltr" class=""><<a href="mailto:estebanlm@gmail.com" target="_blank" class="">estebanlm@gmail.com</a>></span>:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <br class=""><div style="word-wrap:break-word" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 29 Nov 2016, at 13:04, Clément Bera <<a href="mailto:bera.clement@gmail.com" target="_blank" class="">bera.clement@gmail.com</a>> wrote:</div><br class="m_521498899662060592Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi,<div class=""><br class=""></div><div class="">Can you confirm this bug happen only in Windows ?</div></div></div></blockquote><div class=""><br class=""></div>yes, the crash is just in windows.<div class="">the callback problem is general (note that FFICallbackTests works fine, but I think this is related to the fact that it never enters the 2nd condition with the qsort function) .</div><div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">Do you have version number (both VMMaker and git commit) of the last version you have that was working ?</div></div></div></blockquote><div class=""><br class=""></div><div class="">sadly, not… I tried to get the latest working version, but with the mess I have to get the VM to build with opensmalltalk-vm, I couldn’t track it. </div><div class="">I suspect is related to the work on 64bits for windows, but I have no proof of that :P</div><div class=""><br class=""></div><div class="">Esteban</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">Thanks.</div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Nov 29, 2016 at 11:54 AM, Esteban Lorenzano <span dir="ltr" class=""><<a href="mailto:estebanlm@gmail.com" target="_blank" class="">estebanlm@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br class="">
Hi,<br class="">
<br class="">
So, I’m building the PharoVM along with all his dependencies. For me, this is a major step because I can drop the old build process finally.<br class="">
Now, I’m having serious problems with FFI (that they were not present before), :<br class="">
<br class="">
<br class="">
1. CRASH IN WINDOWS (32bits):<br class="">
<br class="">
In Win32, it crashes automatically when trying to access this funtion:<br class="">
<br class="">
getEnvSize: nameString<br class="">
        ^ self ffiCall: #( int GetEnvironmentVariableA ( String nameString, nil, 0 ) ) module: #Kernel32<br class="">
<br class="">
 (this works perfectly fine in older versions)<br class="">
<br class="">
2. CALLBACKS FAILING:<br class="">
<br class="">
Callbacks have problems. The examples passes but they are very simple… as soon as I try to do something complicates (like unqlite bindings or libgit2 bindings, who use callbacks intensively), callbacks stops working.<br class="">
I traced the problem up to this method:<br class="">
<br class="">
StackInterpreter>>#returnAs:Th<wbr class="">roughCallback:Context:<br class="">
<br class="">
returnAs: returnTypeOop ThroughCallback: vmCallbackContext Context: callbackMethodContext<br class="">
        "callbackMethodContext is an activation of invokeCallback:[stack:register<wbr class="">s:jmpbuf:].<br class="">
         Its sender is the VM's state prior to the callback.  Reestablish that state (via longjmp),<br class="">
         and mark callbackMethodContext as dead."<br class="">
        <export: true><br class="">
        <var: #vmCallbackContext type: #'VMCallbackContext *'><br class="">
        | calloutMethodContext theFP thePage |<br class="">
        <var: #theFP type: #'char *'><br class="">
        <var: #thePage type: #'StackPage *'><br class="">
        ((self isIntegerObject: returnTypeOop)<br class="">
         and: [self isLiveContext: callbackMethodContext]) ifFalse:<br class="">
                [^false].<br class="">
        calloutMethodContext := self externalInstVar: SenderIndex ofContext: callbackMethodContext.<br class="">
        (self isLiveContext: calloutMethodContext) ifFalse:<br class="">
                [^false].<br class="">
        "We're about to leave this stack page; must save the current frame's instructionPointer."<br class="">
        self push: instructionPointer.<br class="">
        self externalWriteBackHeadFramePoin<wbr class="">ters.<br class="">
        "Mark callbackMethodContext as dead; the common case is that it is the current frame.<br class="">
         We go the extra mile for the debugger."<br class="">
        (self isSingleContext: callbackMethodContext)<br class="">
                ifTrue: [self markContextAsDead: callbackMethodContext]<br class="">
                ifFalse:<br class="">
                        [theFP := self frameOfMarriedContext: callbackMethodContext.<br class="">
                         framePointer = theFP "common case"<br class="">
                                ifTrue:<br class="">
                                        [(self isBaseFrame: theFP)<br class="">
                                                ifTrue: [stackPages freeStackPage: stackPage]<br class="">
                                                ifFalse: "calloutMethodContext is immediately below on the same page.  Make it current."<br class="">
                                                        [instructionPointer := (self frameCallerSavedIP: framePointer) asUnsignedInteger.<br class="">
                                                         stackPointer := framePointer + (self frameStackedReceiverOffset: framePointer) + objectMemory wordSize.<br class="">
                                                         framePointer := self frameCallerFP: framePointer.<br class="">
                                                         self setMethod: (self frameMethodObject: framePointer).<br class="">
                                                         self restoreCStackStateForCallbackC<wbr class="">ontext: vmCallbackContext.<br class="">
                                                         "N.B. siglongjmp is defines as _longjmp on non-win32 platforms.<br class="">
                                                          This matches the use of _setjmp in ia32abicc.c."<br class="">
                                                         self siglong: vmCallbackContext trampoline jmp: (self integerValueOf: returnTypeOop).<br class="">
                                                         ^true]]<br class="">
                                ifFalse:<br class="">
                                        [self externalDivorceFrame: theFP andContext: callbackMethodContext.<br class="">
                                         self markContextAsDead: callbackMethodContext]].<br class="">
        "Make the calloutMethodContext the active frame.  The case where calloutMethodContext<br class="">
         is immediately below callbackMethodContext on the same page is handled above."<br class="">
        (self isStillMarriedContext: calloutMethodContext)<br class="">
                ifTrue:<br class="">
                        [theFP := self frameOfMarriedContext: calloutMethodContext.<br class="">
                         thePage := stackPages stackPageFor: theFP.<br class="">
                         "findSPOf:on: points to the word beneath the instructionPointer, but<br class="">
                          there is no instructionPointer on the top frame of the current page."<br class="">
                         self assert: thePage ~= stackPage.<br class="">
                         stackPointer := (self findSPOf: theFP on: thePage) - objectMemory wordSize.<br class="">
                         framePointer := theFP]<br class="">
                ifFalse:<br class="">
                        [thePage := self makeBaseFrameFor: calloutMethodContext.<br class="">
                         framePointer := thePage headFP.<br class="">
                         stackPointer := thePage headSP].<br class="">
        instructionPointer := self popStack.<br class="">
        self setMethod: (objectMemory fetchPointer: MethodIndex ofObject: calloutMethodContext).<br class="">
        self setStackPageAndLimit: thePage.<br class="">
        self restoreCStackStateForCallbackC<wbr class="">ontext: vmCallbackContext.<br class="">
         "N.B. siglongjmp is defines as _longjmp on non-win32 platforms.<br class="">
          This matches the use of _setjmp in ia32abicc.c."<br class="">
        self siglong: vmCallbackContext trampoline jmp: (self integerValueOf: returnTypeOop).<br class="">
        "NOTREACHED"<br class="">
        ^true<br class="">
<br class="">
with the first siglongjmp callbacks are passing fine.<br class="">
with the last (it would be if  framePointer = theFP AND !(isBaseFrame: theFP) ) it doesn’t.<br class="">
<br class="">
So… from here I’m a bit lost… I need some help :)<br class="">
<br class="">
thanks,<br class="">
Esteban<br class="">
<br class="">
<br class="">
<br class="">
</blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div><br class=""></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></body></html>