Subject: Bug: setjmp() when profiling enabled
To: NetBSD/Alpha <port-alpha@netbsd.org>
From: B. James Phillippe <bryan-spamtrap0@darkforest.org>
List: port-alpha
Date: 02/18/2002 01:07:23
On the cold day of Feb 16, B. James Phillippe mused:
> Hello,
>
> I am running 1.5.2 on a DEC Alpha, and have bumped into what I believe is
> an unaligned access in the C library. At least, I have an application
> which blows up with "unaligned access" only when compiled with "-pg" for
> profiling. When I run the address through gbd, this is what I get:
Hello,
I still haven't found a solution, but here is some more information. It
seems this problem happens whenever setjmp()/longjmp() are used in an
application which has been compiled with "-pg". Here is a sample program:
/*
* Compile with: gcc -pg test.c
*/
#include <setjmp.h>
jmp_buf env;
int foo(void)
{
int val;
if ((val = setjmp(env)) != 0) { /* <------ boom */
return val;
}
longjmp(env, 1);
return val;
}
int main(int argc, char *argv[])
{
foo();
return 0;
}
The limited testing I'm currently capable of leads me to suspect this is
some kind of stack corruption problem. The problem happens when __setjmp14
is entered after a _mcount has returned within the same stack frame. At
that point, the application will get an unaligned access and then segfault.
I'm hoping someone with experience can take a closer look.
-bp
--
# bryan at darkforest dot org
# Software Engineer