This is the mail archive of the
glibc-bugs@sources.redhat.com
mailing list for the glibc project.
[Bug libc/357] New: getcontext() on ppc32 destroys saved parameter 1 in caller's frame
- From: "qboosh at pld-linux dot org" <sourceware-bugzilla at sources dot redhat dot com>
- To: glibc-bugs at sources dot redhat dot com
- Date: 30 Aug 2004 20:20:19 -0000
- Subject: [Bug libc/357] New: getcontext() on ppc32 destroys saved parameter 1 in caller's frame
- Reply-to: sourceware-bugzilla at sources dot redhat dot com
GLIBC_2.3.4 getcontext() on ppc32 changes the value of the first
parameter passed to caller's function.
Testcase:
$ cat tst_getcontext.c
#include <ucontext.h>
void test(volatile int a, volatile int b)
{
ucontext_t uc;
printf("before: %d %d\n", a, b);
getcontext(&uc);
printf("after : %d %d\n", a, b);
}
int main()
{
test(1, 2);
}
$ ./tst_getcontext
before: 1 2
after : 2147478448 2
("volatile" is not needed when tst_getcontext is compiled without any
optimization)
It's caused by the first instruction of __getcontext()
(sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext.S:29):
ENTRY(__getcontext)
stw r3,_FRAME_PARM_SAVE1(r1)
__getcontext doesn't have its own stack frame, so it uses caller's
stack frame, thus destroying it...
The same applies to GLIBC_2.3.4 swapcontext(), but it may be less/not(?)
harmful as successful swapcontext() never returns.
--
Summary: getcontext() on ppc32 destroys saved parameter 1 in
caller's frame
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: gotom at debian dot or dot jp
ReportedBy: qboosh at pld-linux dot org
CC: glibc-bugs at sources dot redhat dot com
GCC host triplet: ppc-linux
http://sources.redhat.com/bugzilla/show_bug.cgi?id=357
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.