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

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Jan Kratochvil-2
Hi,

currently (on x86_64) the gdb backtrace shows:

#2  0x0000000000400b65 in makeSyscall (ignored=0x0) at threadcrash.c:142
#3  0x00000036ddb0610a in start_thread () from /lib64/tls/libpthread.so.0
#4  0x00000036dd0c68c3 in clone () from /lib64/tls/libc.so.6
#5  0x0000000000000000 in ?? ()

Currently it relies only on clearing %rbp (0x0000000000000000 above is
unrelated to it, it got read from uninitialized memory).

http://sourceware.org/ml/gdb/2004-08/msg00060.html suggests 0x0 should be
enough for a debugger without CFI to stop unwinding, still it is a heuristic.

Provided proper CFI. GDB should also get fixed for the unCFIed functions.


Regards,
Jan

glibc-clone-outermost.patch (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

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

Ulrich Drepper
Applied, but without the URLs.  Those tend to get out-of-date.

--
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
Reply | Threaded
Open this post in threaded view
|

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

Jan Kratochvil-2
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

2006-12-11  Jan Kratochvil  <[hidden email]>

        * 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))

clone-testcase.c (379 bytes) Download Attachment