<p>Here is lldb debug report on OSX:</p>
<pre><code>Process 95068 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x321089be150)
    frame #0: 0x00000001003c58fd Squeak`alphaSourceBlendBits32 at BitBltPlugin.c:820:5
   817 sourceWord = long32At(srcIndex);
   818 srcAlpha = ((usqInt) sourceWord) >> 24;
   819 if (srcAlpha == 0xFF) {
-> 820 long32Atput(dstIndex, sourceWord);
   821 srcIndex += 4;

</code></pre>
<p>we have :</p>
<pre><code>(lldb) p/x dstIndex
(sqInt) $9 = 0x00000321089be150
(lldb) p/x destBits
(sqInt) $14 = 0x00000001089be470

</code></pre>
<p>Wow, <code>dstIndex</code> is very far from <code>destBits</code>... because:</p>
<pre><code>(lldb) p/x dy
(sqInt) $13 = 0x00000000ffffffff
(lldb) p/x dstY
(sqInt) $15 = 0x00000000ffffffff

</code></pre>
<p>Hmm is that intended to be so large? or just -1?<br>
Is it a missing sign extension?<br>
Is -1 a valid value?</p>
<p>it comes from <code>destY</code>, which is set either by BitBlt inst var access:<br>
<code>destY = fetchIntOrFloatofObjectifNil(BBDestYIndex, bitBltOop, 0); </code><br>
or thru balloon support:</p>
<pre><code>EXPORT(sqInt)
copyBitsFromtoat(sqInt startX, sqInt stopX, sqInt yValue)
{
        destX = startX;
        destY = yValue;

</code></pre>
<p>We are in the later case:</p>
<pre><code>(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x321089be150)
  * frame #0: 0x00000001003c58fd Squeak`alphaSourceBlendBits32 at BitBltPlugin.c:820:5
    frame #1: 0x00000001003bf07d Squeak`copyBitsLockedAndClipped at BitBltPlugin.c:1438:3
    frame #2: 0x00000001003b97e6 Squeak`copyBits at BitBltPlugin.c:1257:2
    frame #3: 0x00000001003b9893 Squeak`copyBitsFromtoat(startX=0, stopX=199, yValue=4294967295) at BitBltPlugin.c:1357:2
    frame #4: 0x000000011036eeb4 Squeak3D`b3dDrawSpanBuffer(aet=0x0000000108a313c8, yValue=-1) at b3dMain.c:1146:3
    frame #5: 0x0000000110373d5b Squeak3D`b3dMainLoop(state=0x00000001103aa990, stopReason=0) at b3dMain.c:1448:4
    frame #6: 0x000000011030e1e1 Squeak3D`b3dStartRasterizer at Squeak3D.c:1704:12
    frame #7: 0x00000001000b9cc4 Squeak`primitiveExternalCall at gcc3x-cointerp.c:76948:3

</code></pre>
<p>up the stack, we have:</p>
<pre><code>/* INLINE b3dDrawSpanBuffer(aet, yValue) */
void b3dDrawSpanBuffer(B3DActiveEdgeTable *aet, int yValue)
{
        int leftX, rightX;
        if(aet->size && currentState->spanDrawer) {
                leftX = aet->data[0]->xValue >> B3D_FixedToIntShift;
                rightX = aet->data[aet->size-1]->xValue >> B3D_FixedToIntShift;
                if(leftX < 0) leftX = 0;
                if(rightX > currentState->spanSize) rightX = currentState->spanSize;
                currentState->spanDrawer(leftX, rightX, yValue);
        }
}

</code></pre>
<p>in b3d.h, we have:</p>
<pre><code>        /* Function to call on drawing the output buffer */
        b3dDrawBufferFunction spanDrawer;

</code></pre>
<p>and what is a <code>b3dDrawBufferFunction</code>?<br>
<code>typedef int (*b3dDrawBufferFunction) (int leftX, int rightX, int yValue); </code><br>
OK, so we get a type mismatch on x64...<br>
We pretend that the function expects a 32bits <code>int</code>, when it expects a 64bits <code>sqInt</code>...<br>
Bad, because this type mismatch prevents the sign extension...<br>
Parameter is passed on a 64 bit register, and we get the high bits remaining at 0...</p>
<p>So it's a bit more subtle than pointer stored into int.<br>
Frankly, those type mismatch are a plague.<br>
Levente just corrected a bunch of them recently, but when there is such an indirection thru a function pointer, it's getting unobvious...<br>
Especially when we force with a cast:</p>
<p><code>../src/plugins//Squeak3D/Squeak3D.c: state.spanDrawer = (b3dDrawBufferFunction) copyBitsFn; </code></p>
<pre><code>../src/plugins/Squeak3D/Squeak3D.c:static sqInt copyBitsFn;
../src/plugins/Squeak3D/Squeak3D.c: copyBitsFn = ioLoadFunctionFrom("copyBitsFromtoat", bbPluginName);

```Bah, with all those casts, we let ZERO chance to the compiler to tell us the awfull type mismatch!
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/468?email_source=notifications&email_token=AIJPEW3XQEOS5VQ2FQXRXIDQ5DVFNA5CNFSM4KFNXE22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIVKMZQ#issuecomment-573220454">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AIJPEW6FLINM4Y6BFPOQFQDQ5DVFNANCNFSM4KFNXE2Q">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AIJPEW7QETR2YECNZBUJNX3Q5DVFNA5CNFSM4KFNXE22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIVKMZQ.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/468?email_source=notifications\u0026email_token=AIJPEW3XQEOS5VQ2FQXRXIDQ5DVFNA5CNFSM4KFNXE22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIVKMZQ#issuecomment-573220454",
"url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/468?email_source=notifications\u0026email_token=AIJPEW3XQEOS5VQ2FQXRXIDQ5DVFNA5CNFSM4KFNXE22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIVKMZQ#issuecomment-573220454",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>