Messages in this thread | | | Subject | [BUG mm] "fixed" i386 memcpy inlining buggy | From | Christophe Saout <> | Date | Tue, 05 Apr 2005 18:34:04 +0200 |
| |
Hi Denis,
the new i386 memcpy macro is a ticking timebomb.
I've been debugging a new mISDN crash, just to find out that a memcpy was not inlined correctly.
Andrew, you should drop the fix-i386-memcpy.patch (or have it fixed).
This source code:
mISDN_pid_t pid; [...] memcpy(&st->mgr->pid, &pid, sizeof(mISDN_pid_t));
was compiled as:
lea 0xffffffa4(%ebp),%esi <---- %esi is loaded ( add $0x10,%ebx ) ( mov %ebx,%eax ) something else ( call 1613 <test_stack_protocol+0x83> ) %esi preserved mov 0xffffffa0(%ebp),%edx mov 0x74(%edx),%edi <---- %edi is loaded add $0x20,%edi offset in structure added ! mov $0x14,%esi !!!!!! <---- %esi overwritten! mov %esi,%ecx <---- %ecx loaded repz movsl %ds:(%esi),%es:(%edi)
Apparently the compiled decided that the value 0x14 could be reused afterwards (which it does for an inlined memset of the same size some instructions below) and clobbers %esi.
Looking at the macro:
__asm__ __volatile__( "" : "=&D" (edi), "=&S" (esi) : "0" ((long) to),"1" ((long) from) : "memory" ); } if (n >= 5*4) { /* large block: use rep prefix */ int ecx; __asm__ __volatile__( "rep ; movsl" : "=&c" (ecx)
it seems obvious that the compiled assumes it can reuse %esi and %edi for something else between the two __asm__ sections. These should probably be merged.
[unhandled content-type:application/pgp-signature] | |