This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC PATCH] sysdeps/i386/i686/memcmp.S has incorrect unwind info


Greetings,

sysdeps/i386/i686/memcmp.S erroneously double-counts the initial
'pushl %ebx': once as part of the RETURN macro, and again on
lines 79-80.

Attached patch fixes that.

The program below intentionally crashes inside memcmp().
The gdb session shows that gdb is unable to unwind the stack
correctly.

#include <string.h>
int main()
{
  char buf[4];
  return memcmp((void *)0x123, buf, 12);
}

Compiled in 32-bit mode, and analyzed with gdb:

Program received signal SIGSEGV, Segmentation fault.
0xf7f0f628 in memcmp () from /home/ppluzhnikov/build-glibc-cvs-32/libc.so.6
(gdb) bt
#0  0xf7f0f628 in memcmp () from /home/ppluzhnikov/build-glibc-cvs-32/libc.so.6
#1  0x00000123 in ?? ()
#2  0xffffd830 in ?? ()
#3  0x0000000c in ?? ()
#4  0x08048309 in _init ()
#5  0xf7eb85d8 in __libc_start_main (main=0x80481f8 <main>, argc=1, ubp_av=0xffffd8d4, init=0x804827a <__libc_csu_init>, fini=0x8048230 <__libc_csu_fini>,
   rtld_fini=0xf7fef3e0 <_dl_fini>, stack_end=0xffffd8cc) at libc-start.c:220
#6  0x08048175 in _start ()
(gdb) q

After the patch, gdb shows correct stack trace:

Program received signal SIGSEGV, Segmentation fault.
0xf7f0f628 in memcmp () from /home/ppluzhnikov/build-glibc-cvs-32/libc.so.6
(gdb) bt
#0  0xf7f0f628 in memcmp () from /home/ppluzhnikov/build-glibc-cvs-32/libc.so.6
#1  0x08048224 in main () at t.c:6


Thanks,

--
Paul Pluzhnikov



Index: sysdeps/i386/i686/memcmp.S
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/i386/i686/memcmp.S,v
retrieving revision 1.8
diff -u -p -u -r1.8 memcmp.S
--- sysdeps/i386/i686/memcmp.S	3 Dec 2006 23:15:10 -0000	1.8
+++ sysdeps/i386/i686/memcmp.S	15 Jul 2008 22:08:14 -0000
@@ -76,8 +76,6 @@ L(neq):
 	sbbl	$-1, %eax
 	RETURN
 
-	cfi_adjust_cfa_offset (4)
-	cfi_rel_offset (ebx, 0)
 L(not_1):
 	jl	L(bye)			/* LEN == 0  */
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]