public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/357] New: getcontext() on ppc32 destroys saved parameter 1 in caller's frame
@ 2004-08-30 20:20 qboosh at pld-linux dot org
2004-08-30 23:22 ` [Bug libc/357] " sjmunroe at us dot ibm dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: qboosh at pld-linux dot org @ 2004-08-30 20:20 UTC (permalink / raw)
To: glibc-bugs
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libc/357] getcontext() on ppc32 destroys saved parameter 1 in caller's frame
2004-08-30 20:20 [Bug libc/357] New: getcontext() on ppc32 destroys saved parameter 1 in caller's frame qboosh at pld-linux dot org
@ 2004-08-30 23:22 ` sjmunroe at us dot ibm dot com
2004-08-31 6:24 ` aj at suse dot de
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: sjmunroe at us dot ibm dot com @ 2004-08-30 23:22 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From sjmunroe at us dot ibm dot com 2004-08-30 23:22 -------
Created an attachment (id=179)
--> (http://sources.redhat.com/bugzilla/attachment.cgi?id=179&action=view)
Here is a patch to try
This patch fixes the problem in the testcase and preserves all registers except
R3. It was the minimum change that would work. But Paul Mackerras points out I
don't really have to perserve any of the volatile registers and burning a few
more registers would speed the code up a bit. I'll look at that tomorrow.
--
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libc/357] getcontext() on ppc32 destroys saved parameter 1 in caller's frame
2004-08-30 20:20 [Bug libc/357] New: getcontext() on ppc32 destroys saved parameter 1 in caller's frame qboosh at pld-linux dot org
2004-08-30 23:22 ` [Bug libc/357] " sjmunroe at us dot ibm dot com
@ 2004-08-31 6:24 ` aj at suse dot de
2004-08-31 21:07 ` qboosh at pld-linux dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: aj at suse dot de @ 2004-08-31 6:24 UTC (permalink / raw)
To: glibc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|gotom at debian dot or dot |sjmunroe at us dot ibm dot
|jp |com
Status|NEW |ASSIGNED
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libc/357] getcontext() on ppc32 destroys saved parameter 1 in caller's frame
2004-08-30 20:20 [Bug libc/357] New: getcontext() on ppc32 destroys saved parameter 1 in caller's frame qboosh at pld-linux dot org
2004-08-30 23:22 ` [Bug libc/357] " sjmunroe at us dot ibm dot com
2004-08-31 6:24 ` aj at suse dot de
@ 2004-08-31 21:07 ` qboosh at pld-linux dot org
2004-09-02 18:44 ` sjmunroe at us dot ibm dot com
2004-09-03 8:09 ` jakub at redhat dot com
4 siblings, 0 replies; 6+ messages in thread
From: qboosh at pld-linux dot org @ 2004-08-31 21:07 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From qboosh at pld-linux dot org 2004-08-31 21:07 -------
Patch fixes problem for me (both in attached testcase and real-world application
on which I discovered it).
--
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libc/357] getcontext() on ppc32 destroys saved parameter 1 in caller's frame
2004-08-30 20:20 [Bug libc/357] New: getcontext() on ppc32 destroys saved parameter 1 in caller's frame qboosh at pld-linux dot org
` (2 preceding siblings ...)
2004-08-31 21:07 ` qboosh at pld-linux dot org
@ 2004-09-02 18:44 ` sjmunroe at us dot ibm dot com
2004-09-03 8:09 ` jakub at redhat dot com
4 siblings, 0 replies; 6+ messages in thread
From: sjmunroe at us dot ibm dot com @ 2004-09-02 18:44 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From sjmunroe at us dot ibm dot com 2004-09-02 18:44 -------
Created an attachment (id=183)
--> (http://sources.redhat.com/bugzilla/attachment.cgi?id=183&action=view)
Final patch with testcase update
Since I have to stack a frame anyway burning more volatiles does not buy much.
So I started with the privious patch and improved the scheduling.
--
What |Removed |Added
----------------------------------------------------------------------------
Attachment #179 is|0 |1
obsolete| |
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libc/357] getcontext() on ppc32 destroys saved parameter 1 in caller's frame
2004-08-30 20:20 [Bug libc/357] New: getcontext() on ppc32 destroys saved parameter 1 in caller's frame qboosh at pld-linux dot org
` (3 preceding siblings ...)
2004-09-02 18:44 ` sjmunroe at us dot ibm dot com
@ 2004-09-03 8:09 ` jakub at redhat dot com
4 siblings, 0 replies; 6+ messages in thread
From: jakub at redhat dot com @ 2004-09-03 8:09 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From jakub at redhat dot com 2004-09-03 08:09 -------
Should be fixed in CVS.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-09-03 8:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-30 20:20 [Bug libc/357] New: getcontext() on ppc32 destroys saved parameter 1 in caller's frame qboosh at pld-linux dot org
2004-08-30 23:22 ` [Bug libc/357] " sjmunroe at us dot ibm dot com
2004-08-31 6:24 ` aj at suse dot de
2004-08-31 21:07 ` qboosh at pld-linux dot org
2004-09-02 18:44 ` sjmunroe at us dot ibm dot com
2004-09-03 8:09 ` jakub at redhat dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).