[PATCH] Unwinding CFI stop at the outermost clone()

Jan Kratochvil jan.kratochvil@redhat.com
Mon Dec 11 19:03:00 GMT 2006


Hi Ulrich,

please temporarily remove the patch as there are compatibility problems with it
needing update of the libgcc_s unwinder (*).  After its accepted update I hope
the patch can get back.

Problem reported and analysed by Jakub Jelinek.  His modified testcase output:
	/tmp/clone-testcase[0x4005eb]
	/lib64/libpthread.so.0[0x3f234061b5]
	/lib64/libc.so.6(clone+0x6d)[0x3f22ccd39d]
	/lib64/libc.so.6(clone+0x6d)[0x3f22ccd39d]
	[...stuck]


Thanks,
Jan

(*) such as for libunwind:
    http://sources.redhat.com/cgi-bin/cvsweb.cgi/frysk-imports/libunwind/src/dwarf/Gparser.c.diff?r1=1.3&r2=1.4&cvsroot=frysk
-------------- next part --------------
2006-12-11  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* sysdeps/unix/sysv/linux/i386/clone.S: Revert the patch of 2006-11-30.
	At least the libgcc_s unwinder needs to handle `.cfi_undefined' first.
	* sysdeps/unix/sysv/linux/x86_64/clone.S: Likewise.


Index: sysdeps/unix/sysv/linux/i386/clone.S
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/i386/clone.S,v
retrieving revision 1.27
retrieving revision 1.26
diff -u -p -r1.27 -r1.26
--- sysdeps/unix/sysv/linux/i386/clone.S	3 Dec 2006 23:12:36 -0000	1.27
+++ sysdeps/unix/sysv/linux/i386/clone.S	4 May 2005 17:52:08 -0000	1.26
@@ -120,9 +120,6 @@ L(pseudo_end):
 	ret
 
 L(thread_start):
-	cfi_startproc;
-	/* Clearing frame pointer is insufficient, use CFI.  */
-	cfi_undefined (eip);
 	/* Note: %esi is zero.  */
 	movl	%esi,%ebp	/* terminate the stack frame */
 #ifdef RESET_PID
@@ -155,7 +152,6 @@ L(nomoregetpid):
 	jmp	L(haspid)
 	.previous
 #endif
-	cfi_endproc;
 
 	cfi_startproc
 PSEUDO_END (BP_SYM (__clone))
Index: sysdeps/unix/sysv/linux/x86_64/clone.S
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/x86_64/clone.S,v
retrieving revision 1.7
retrieving revision 1.6
diff -u -p -r1.7 -r1.6
--- sysdeps/unix/sysv/linux/x86_64/clone.S	3 Dec 2006 23:12:36 -0000	1.7
+++ sysdeps/unix/sysv/linux/x86_64/clone.S	31 Mar 2005 10:00:12 -0000	1.6
@@ -89,9 +89,6 @@ L(pseudo_end):
 	ret
 
 L(thread_start):
-	cfi_startproc;
-	/* Clearing frame pointer is insufficient, use CFI.  */
-	cfi_undefined (rip);
 	/* Clear the frame pointer.  The ABI suggests this be done, to mark
 	   the outermost frame obviously.  */
 	xorl	%ebp, %ebp
@@ -116,7 +113,6 @@ L(thread_start):
 	/* Call exit with return value from function call. */
 	movq	%rax, %rdi
 	call	HIDDEN_JUMPTARGET (_exit)
-	cfi_endproc;
 
 	cfi_startproc;
 PSEUDO_END (BP_SYM (__clone))
-------------- next part --------------
#include <pthread.h>
#include <execinfo.h>
#include <stdio.h>
#include <unistd.h>
void *
tf (void *arg)
{
  void *buf[512];
  int i = backtrace (buf, 512);
  printf ("%d\n", i);
  backtrace_symbols_fd (buf, i, STDOUT_FILENO);
  return NULL;
}
int
main (void)
{
  pthread_t th;
  pthread_create (&th, NULL, tf, NULL);
  pthread_join (th, NULL);
  return 0;
}


More information about the Libc-alpha mailing list