<div dir="ltr">Hi,<div><br></div><div>Can you confirm this bug happen only in Windows ?</div><div><br></div><div>Do you have version number (both VMMaker and git commit) of the last version you have that was working ?</div><div><br></div><div>Thanks.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 29, 2016 at 11:54 AM, Esteban Lorenzano <span dir="ltr"><<a href="mailto:estebanlm@gmail.com" target="_blank">estebanlm@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi,<br>
<br>
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>
Now, I’m having serious problems with FFI (that they were not present before), :<br>
<br>
<br>
1. CRASH IN WINDOWS (32bits):<br>
<br>
In Win32, it crashes automatically when trying to access this funtion:<br>
<br>
getEnvSize: nameString<br>
^ self ffiCall: #( int GetEnvironmentVariableA ( String nameString, nil, 0 ) ) module: #Kernel32<br>
<br>
(this works perfectly fine in older versions)<br>
<br>
2. CALLBACKS FAILING:<br>
<br>
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>
I traced the problem up to this method:<br>
<br>
StackInterpreter>>#returnAs:<wbr>ThroughCallback:Context:<br>
<br>
returnAs: returnTypeOop ThroughCallback: vmCallbackContext Context: callbackMethodContext<br>
"callbackMethodContext is an activation of invokeCallback:[stack:<wbr>registers:jmpbuf:].<br>
Its sender is the VM's state prior to the callback. Reestablish that state (via longjmp),<br>
and mark callbackMethodContext as dead."<br>
<export: true><br>
<var: #vmCallbackContext type: #'VMCallbackContext *'><br>
| calloutMethodContext theFP thePage |<br>
<var: #theFP type: #'char *'><br>
<var: #thePage type: #'StackPage *'><br>
((self isIntegerObject: returnTypeOop)<br>
and: [self isLiveContext: callbackMethodContext]) ifFalse:<br>
[^false].<br>
calloutMethodContext := self externalInstVar: SenderIndex ofContext: callbackMethodContext.<br>
(self isLiveContext: calloutMethodContext) ifFalse:<br>
[^false].<br>
"We're about to leave this stack page; must save the current frame's instructionPointer."<br>
self push: instructionPointer.<br>
self externalWriteBackHeadFramePoin<wbr>ters.<br>
"Mark callbackMethodContext as dead; the common case is that it is the current frame.<br>
We go the extra mile for the debugger."<br>
(self isSingleContext: callbackMethodContext)<br>
ifTrue: [self markContextAsDead: callbackMethodContext]<br>
ifFalse:<br>
[theFP := self frameOfMarriedContext: callbackMethodContext.<br>
framePointer = theFP "common case"<br>
ifTrue:<br>
[(self isBaseFrame: theFP)<br>
ifTrue: [stackPages freeStackPage: stackPage]<br>
ifFalse: "calloutMethodContext is immediately below on the same page. Make it current."<br>
[instructionPointer := (self frameCallerSavedIP: framePointer) asUnsignedInteger.<br>
stackPointer := framePointer + (self frameStackedReceiverOffset: framePointer) + objectMemory wordSize.<br>
framePointer := self frameCallerFP: framePointer.<br>
self setMethod: (self frameMethodObject: framePointer).<br>
self restoreCStackStateForCallbackC<wbr>ontext: vmCallbackContext.<br>
"N.B. siglongjmp is defines as _longjmp on non-win32 platforms.<br>
This matches the use of _setjmp in ia32abicc.c."<br>
self siglong: vmCallbackContext trampoline jmp: (self integerValueOf: returnTypeOop).<br>
^true]]<br>
ifFalse:<br>
[self externalDivorceFrame: theFP andContext: callbackMethodContext.<br>
self markContextAsDead: callbackMethodContext]].<br>
"Make the calloutMethodContext the active frame. The case where calloutMethodContext<br>
is immediately below callbackMethodContext on the same page is handled above."<br>
(self isStillMarriedContext: calloutMethodContext)<br>
ifTrue:<br>
[theFP := self frameOfMarriedContext: calloutMethodContext.<br>
thePage := stackPages stackPageFor: theFP.<br>
"findSPOf:on: points to the word beneath the instructionPointer, but<br>
there is no instructionPointer on the top frame of the current page."<br>
self assert: thePage ~= stackPage.<br>
stackPointer := (self findSPOf: theFP on: thePage) - objectMemory wordSize.<br>
framePointer := theFP]<br>
ifFalse:<br>
[thePage := self makeBaseFrameFor: calloutMethodContext.<br>
framePointer := thePage headFP.<br>
stackPointer := thePage headSP].<br>
instructionPointer := self popStack.<br>
self setMethod: (objectMemory fetchPointer: MethodIndex ofObject: calloutMethodContext).<br>
self setStackPageAndLimit: thePage.<br>
self restoreCStackStateForCallbackC<wbr>ontext: vmCallbackContext.<br>
"N.B. siglongjmp is defines as _longjmp on non-win32 platforms.<br>
This matches the use of _setjmp in ia32abicc.c."<br>
self siglong: vmCallbackContext trampoline jmp: (self integerValueOf: returnTypeOop).<br>
"NOTREACHED"<br>
^true<br>
<br>
with the first siglongjmp callbacks are passing fine.<br>
with the last (it would be if framePointer = theFP AND !(isBaseFrame: theFP) ) it doesn’t.<br>
<br>
So… from here I’m a bit lost… I need some help :)<br>
<br>
thanks,<br>
Esteban<br>
<br>
<br>
<br>
</blockquote></div><br></div>