public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* Backtrace problems from a signal handler
@ 2005-07-25  5:29 Keith Owens
  2005-07-27  1:09 ` Keith Owens
  0 siblings, 1 reply; 2+ messages in thread
From: Keith Owens @ 2005-07-25  5:29 UTC (permalink / raw)
  To: linux-ia64

gdb with libunwind support does not unwind correctly if a signal
handler calls another function which then takes a core dump.

SuSE SLES9 SP2.  gdb-6.3-16.4.  libunwind-0.98.5-3.2.  gcc 3.3.3.

% cat signal-test.c
#include <signal.h>

void foo(void)
{
	*(char *)0 = 1;
}

static void handler(int sig)
{
	foo();
}

int main(void)
{
	signal(SIGALRM, handler);
	kill(0, SIGALRM);
	return 0;
}

% make CFLAGS="-Wall -g" signal-test
% ulimit -c unlimited
% ./signal-test
% gdb signal-test core
(gdb) bt
#0  foo () at signal-test.c:5
#1  0x40000000000006e0 in handler (sig\x14) at signal-test.c:10
#2  <signal handler called>
Previous frame inner to this frame (corrupt stack?)

Running under gdb and setting a breakpoint on foo() has exactly the
same problem.  IOW, this is not being caused by the core dump, it is
purely an unwind problem.

If the handler does '*(char *)0 = 1;' directly instead of calling foo()
then the backtrace works.

(gdb) bt
#0  handler (sig\x14) at signal-test.c:10
#1  <signal handler called>
#2  0xa000000000010640 in ?? ()
#3  0x20000000000a8a80 in kill () from /lib/tls/libc.so.6.1
#4  0x4000000000000780 in main () at signal-test.c:17

This problem tends to be reported against abort() because that is
usually the function that starts the core dump, but my tests show that
abort() is innocent.  Calling any function from a signal handler stuffs
up the backtrace.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Backtrace problems from a signal handler
  2005-07-25  5:29 Backtrace problems from a signal handler Keith Owens
@ 2005-07-27  1:09 ` Keith Owens
  0 siblings, 0 replies; 2+ messages in thread
From: Keith Owens @ 2005-07-27  1:09 UTC (permalink / raw)
  To: linux-ia64

On Mon, 25 Jul 2005 15:29:12 +1000, 
Keith Owens <kaos@sgi.com> wrote:
>gdb with libunwind support does not unwind correctly if a signal
>handler calls another function which then takes a core dump.
>
>SuSE SLES9 SP2.  gdb-6.3-16.4.  libunwind-0.98.5-3.2.  gcc 3.3.3.

David Mosberger suggested checking the CVS version of gdb.  The
gdb-6.3.50.20050726 snapshot handles backtrace through a signal
handler when the handler calls another function.

Program received signal SIGABRT, Aborted.
0xa000000000010641 in __kernel_syscall_via_break ()
(gdb) bt
#0  0xa000000000010641 in __kernel_syscall_via_break ()
#1  0x20000000000a8690 in raise () from /lib/tls/libc.so.6.1
#2  0x20000000000aadf0 in abort () from /lib/tls/libc.so.6.1
#3  0x4000000000000740 in foo () at signal-test.c:6
#4  0x4000000000000780 in handler (sig\x14) at signal-test.c:12
#5  <signal handler called>
#6  0xa000000000010640 in __kernel_syscall_via_break ()
#7  0x20000000000a8a80 in kill () from /lib/tls/libc.so.6.1
#8  0x4000000000000810 in main () at signal-test.c:18


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-07-27  1:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-25  5:29 Backtrace problems from a signal handler Keith Owens
2005-07-27  1:09 ` Keith Owens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox