<br><br><div class="gmail_quote">On Tue, Aug 24, 2010 at 8:11 PM, Igor Stasenko <span dir="ltr">&lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><br>
On 25 August 2010 04:39, Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Hi Levente,<br>
&gt;     essentially correct.  The bug was caused by an incorrect asm.  Changing<br>
&gt; #   define BYTE_SWAP(w) __asm__(&quot;bswap %%eax&quot; : &quot;=r&quot; (w) : &quot;r&quot; (w))<br>
&gt; #   define WORD_SWAP(w) __asm__(&quot;roll $16, %%eax&quot; : &quot;=r&quot; (w) : &quot;r&quot; (w))<br>
&gt; to<br>
&gt; #   define BYTE_SWAP(w) __asm__(&quot;bswap %0&quot; : &quot;=r&quot; (w) : &quot;r&quot; (w))<br>
&gt; #   define WORD_SWAP(w) __asm__(&quot;roll $16, %0&quot; : &quot;=r&quot; (w) : &quot;r&quot; (w))<br>
&gt; in platforms/win32/vm/sqWin32Window.c&#39;s byte &amp; word image reversal code fixes it.  This worked back on 2.95.x because it always chose $eax as the register for the value variable in<br>
&gt; unsigned int value = *srcPixPtr++;<br>
&gt; but gcc 3.x is more devious.<br>
&gt; I&#39;ve updated svn and will upload a new engine soon.<br>
&gt; thanks,<br>
&gt; Eliot<br>
&gt;<br>
</div>Hmm.. interesting, how changing a byte order could cause a crash?<br>
A windows blitter using byte reversal logic when blitting a big-endian<br>
forms on windows GDI (since on windows its little-endian,<br>
it swaps form&#39;s bits, then copying bits, and then swaps back again)..<br>
but still i don&#39;t understand how this may cause a crash.. it may cause<br>
problems with seeing anything correct on a screen.<br></blockquote><div><br></div><div>#   define BYTE_SWAP(w) __asm__(&quot;bswap %%eax&quot; : &quot;=r&quot; (w) : &quot;r&quot; (w))</div><div><br></div><div>causes $eax to be byte-swapped irrespective of its use.  In gcc 3.4.4 and the code in question $eax contained a loop limit which caused an out-of-range memory read.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5"><br>
&gt; On Sun, Aug 22, 2010 at 1:56 PM, Levente Uzonyi &lt;<a href="mailto:leves@elte.hu">leves@elte.hu</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi,<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; evaluating [Display newDepth: x] where the value of x is 1, 4, 8 or 16 crashes the VM. No crash dump is written. If x is 2, -1, -2 or -4, then the image informs me that the depth is not available on the system. If x is -8 or -16 then the code works. For the x=16 case gdb shows the following:<br>

&gt;&gt;<br>
&gt;&gt; Program received signal SIGSEGV, Segmentation fault.<br>
&gt;&gt; reverse_image_words (dst=0x1450eca4, src=0x1450eca4, depth=0, width=1272,<br>
&gt;&gt;    rect=0x561e60) at ../platforms/win32/vm/sqWin32Window.c:1875<br>
&gt;&gt; 1875            unsigned int value = *srcPixPtr++;<br>
&gt;&gt; (gdb) where<br>
&gt;&gt; #0  reverse_image_words (dst=0x1450eca4, src=0x1450eca4, depth=0, width=1272,<br>
&gt;&gt;    rect=0x561e60) at ../platforms/win32/vm/sqWin32Window.c:1875<br>
&gt;&gt; #1  0x0043f61a in ioShowDisplay (dispBits=340847780, width=1272, height=745,<br>
&gt;&gt;    depth=16, affectedL=0, affectedR=1000, affectedT=0, affectedB=0)<br>
&gt;&gt;    at ../platforms/win32/vm/sqWin32Window.c:2324<br>
&gt;&gt; #2  0x00403270 in displayBitsOfLeftTopRightBottom (aForm=-719257650, l=0,<br>
&gt;&gt;    t=0, r=1272, b=745) at ../src/vm/gcc3x-cointerp.c:13701<br>
&gt;&gt; #3  0x00405ff9 in fullDisplayUpdate () at ../src/vm/gcc3x-cointerp.c:16777<br>
&gt;&gt; #4  0x0044093a in MainWndProcW (hwnd=0xf05f6, message=15, wParam=0, lParam=0)<br>
&gt;&gt;    at ../platforms/win32/vm/sqWin32Window.c:447<br>
&gt;&gt; #5  0x75fef8d2 in USER32!GetMessageW ()<br>
&gt;&gt;   from /cygdrive/c/Windows/system32/user32.dll<br>
&gt;&gt; #6  0x75fef794 in USER32!GetWindowLongW ()<br>
&gt;&gt;   from /cygdrive/c/Windows/system32/user32.dll<br>
&gt;&gt; #7  0x004403dc in sqLaunchDrop ()<br>
&gt;&gt;    at ../platforms/win32/vm/sqWin32Window.c:2773<br>
&gt;&gt; #8  0x75ff0817 in USER32!ReleaseDC ()<br>
&gt;&gt;   from /cygdrive/c/Windows/system32/user32.dll<br>
&gt;&gt; #9  0x75ff0a65 in USER32!GetWindowThreadProcessId ()<br>
&gt;&gt;   from /cygdrive/c/Windows/system32/user32.dll<br>
&gt;&gt; #10 0x776a99ce in ntdll!LdrEnumResources ()<br>
&gt;&gt;   from /cygdrive/c/Windows/system32/ntdll.dll<br>
&gt;&gt; #11 0x00ace008 in ?? ()<br>
&gt;&gt; #12 0x00000018 in ?? ()<br>
&gt;&gt; ---Type &lt;return&gt; to continue, or q &lt;return&gt; to quit---<br>
&gt;&gt; #13 0x00ace058 in ?? ()<br>
&gt;&gt; #14 0x776a9980 in ntdll!LdrDisableThreadCalloutsForDll ()<br>
&gt;&gt;   from /cygdrive/c/Windows/system32/ntdll.dll<br>
&gt;&gt; #15 0x0204c1d8 in ?? ()<br>
&gt;&gt; #16 0x0000000f in ?? ()<br>
&gt;&gt; #17 0x00000000 in ?? ()<br>
&gt;&gt; (gdb) info registers<br>
&gt;&gt; eax            0xd520ffce       -719257650<br>
&gt;&gt; ecx            0x3      3<br>
&gt;&gt; edx            0x0      0<br>
&gt;&gt; ebx            0x1f4    500<br>
&gt;&gt; esp            0xacd5b4 0xacd5b4<br>
&gt;&gt; ebp            0x0      0x0<br>
&gt;&gt; esi            0x1511a000       353476608<br>
&gt;&gt; edi            0x1511a000       353476608<br>
&gt;&gt; eip            0x43ed0c 0x43ed0c &lt;reverse_image_words+353&gt;<br>
&gt;&gt; eflags         0x10216  [ PF AF IF RF ]<br>
&gt;&gt; cs             0x1b     27<br>
&gt;&gt; ss             0x23     35<br>
&gt;&gt; ds             0x23     35<br>
&gt;&gt; es             0x23     35<br>
&gt;&gt; fs             0x3b     59<br>
&gt;&gt; gs             0x0      0<br>
&gt;&gt;<br>
&gt;&gt; It may be a compiler bug, because the 4.0.2 SqueakVM doesn&#39;t have this issue. It&#39;s a bit suspicious that depth is 0 here:<br>
&gt;&gt; #0  reverse_image_words (dst=0x1450eca4, src=0x1450eca4, depth=0, width=1272,<br>
&gt;&gt;    rect=0x561e60) at ../platforms/win32/vm/sqWin32Window.c:1875<br>
&gt;&gt; but the value of depth is known at compilation time (16), so it may be some compiler &quot;magic&quot;.<br>
&gt;&gt; Here are the values of the variables in the method:<br>
&gt;&gt; (gdb) p dst<br>
&gt;&gt; $2 = (unsigned int *) 0x1450eca4<br>
&gt;&gt; (gdb) p src<br>
&gt;&gt; $3 = (unsigned int *) 0x1450eca4<br>
&gt;&gt; (gdb) p depth<br>
&gt;&gt; $4 = 0<br>
&gt;&gt; (gdb) p width<br>
&gt;&gt; $5 = 1272<br>
&gt;&gt; (gdb) p rect<br>
&gt;&gt; $6 = (RECT *) 0x561e60<br>
&gt;&gt; (gdb) p rect-&gt;left<br>
&gt;&gt; $7 = 0<br>
&gt;&gt; (gdb) p rect-&gt;right<br>
&gt;&gt; $8 = 1000<br>
&gt;&gt; (gdb) p rect-&gt;top<br>
&gt;&gt; $9 = 0<br>
&gt;&gt; (gdb) p rect-&gt;bottom<br>
&gt;&gt; $10 = 745<br>
&gt;&gt; (gdb) p pitch<br>
&gt;&gt; $11 = 353476608<br>
&gt;&gt; (gdb) p first<br>
&gt;&gt; $12 = 3<br>
&gt;&gt; (gdb) p last<br>
&gt;&gt; No symbol &quot;last&quot; in current context.<br>
&gt;&gt; (gdb) p nWords<br>
&gt;&gt; $13 = 500<br>
&gt;&gt; (gdb) p delta<br>
&gt;&gt; $14 = 0<br>
&gt;&gt; (gdb) p yy<br>
&gt;&gt; $15 = 0<br>
&gt;&gt; (gdb) p srcPixPtr<br>
&gt;&gt; $16 = (DWORD *) 0x1511a000<br>
&gt;&gt; (gdb) p dstPixPtr<br>
&gt;&gt; $17 = (DWORD *) 0x1511a000<br>
&gt;&gt; (gdb) p i<br>
&gt;&gt; $18 = -719257650<br>
&gt;&gt; (gdb) p value<br>
&gt;&gt; $19 = 0<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Cheers,<br>
&gt;&gt; Levente<br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
<br>
<br>
</div></div><font color="#888888">--<br>
Best regards,<br>
Igor Stasenko AKA sig.<br>
</font></blockquote></div><br>