This is the mail archive of the
glibc-bugs@sources.redhat.com
mailing list for the glibc project.
[Bug libc/269] New: PPC64 bit longjmp doesn't establish saved TOC properly
- From: "sjmunroe at us dot ibm dot com" <sourceware-bugzilla at sources dot redhat dot com>
- To: glibc-bugs at sources dot redhat dot com
- Date: 16 Jul 2004 17:29:57 -0000
- Subject: [Bug libc/269] New: PPC64 bit longjmp doesn't establish saved TOC properly
- Reply-to: sourceware-bugzilla at sources dot redhat dot com
Mark Mendell <mendell@ca.ibm.com> reports:
Hardware Environment:
p690 (actually any 64 bit PPC)
Software Environment:
RHEL 3 QU2 and SLES9 RC5
Steps to Reproduce:
1. t.c:
#include <setjmp.h>
jmp_buf buf1;
jmp_buf buf2;
int *p;
int n_x = 6;
static int g_counter = 0;
#define g(x) \
{ \
int a[n_x], i; \
g_counter++; \
p = &a[0]; \
if( g_counter < 5 ) longjmp(buf1, 2); \
else if( g_counter == 5 ) longjmp(buf1, 101); \
else { setjmp(buf2); longjmp(buf1, 101); } \
}
int f(int n)
{
static int counter = 0;
int i;
if( setjmp(buf1) != 101 ) {
g(6);
}
if( counter == 0 ) {
counter++;
g(6);
}
if( counter == 1 ) {
counter++;
longjmp(buf2, 2);
}
return n;
}
int main( )
{
f(6);
}
2. gcc -m64 t.c; a.out
Actual Results:
Segmentation fault
Expected Results:
<none>
Additional Information:
This is a previously seen problem with longjmp on AIX. It is essential that
longjmp store gpr2 at 40(sp) before returning to the user program. This is
because the call to setjmp is probably followed by a reload of gpr2. If an
alloca (or VLA in C99) has been done between the setjmp and the longjmp, then
the saved TOC at 40(sp) may not be set. The easiest fix is to add
'std r2,40(r1)' to the end of longjmp just before returning to the user code.
This was actually seen with a similar program compiled with xlc at -O4, but
I rewrote it for general distribution.
--
Summary: PPC64 bit longjmp doesn't establish saved TOC properly
Product: glibc
Version: 2.3.3
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: gotom at debian dot or dot jp
ReportedBy: sjmunroe at us dot ibm dot com
CC: glibc-bugs at sources dot redhat dot com,sjmunroe at us
dot ibm dot com
GCC host triplet: powerpc64--linux
http://sources.redhat.com/bugzilla/show_bug.cgi?id=269
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.