This is the mail archive of the
glibc-bugs@sources.redhat.com
mailing list for the glibc project.
[Bug libc/759] New: getcontext() not setting arg's uc_stack correctly
- From: "marques at cs dot cornell dot edu" <sourceware-bugzilla at sources dot redhat dot com>
- To: glibc-bugs at sources dot redhat dot com
- Date: 23 Feb 2005 19:23:18 -0000
- Subject: [Bug libc/759] New: getcontext() not setting arg's uc_stack correctly
- Reply-to: sourceware-bugzilla at sources dot redhat dot com
Hi. I reported this via the glibcbug email script, but I did not receive any
notification. Sorry if I am being repetetive by posting here.
>>Confidential: no
>>Synopsis: getcontext() is not setting its argument's uc_stack ss_sp and
ss_size fields correctly
>>Severity: non-critical
>>Priority: medium
>>Category: libc
>>Class: sw-bug
>>Release: libc-2.3.2
>>Environment:
Host type: i386-redhat-linux-gnu
System: Linux c3linux.u.cs.cornell.edu 2.4.20-31.9 #1 Tue Apr 13 18:04:23 EDT
2004 i686 i686 i386 GNU/Linux
Architecture: i686
Addons: linuxthreads c_stubs glibc-compat
Build CFLAGS: -march=i386 -DNDEBUG=1 -finline-limit=2000 -g -O3
Build CC: gcc
Compiler version: 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
Kernel headers: 2.4.20
Symbol versioning: yes
Build static: yes
Build shared: yes
Build pic-default: no
Build profile: yes
Build omitfp: no
Build bounded: no
Build static-nss: no
>>Description:
After getcontext(&my_context) returns, the fields
my_context.uc_stack.ss_sp and my_context.uc_stack.ss_size
are not set to the correct values for the current context.
In fact, they hold NULL, and 0, respectively.
For example, compiling and running the source in the
"How-To-Repeat" section, produces the following output (on the
machine specified above).
[marques@c3linux sample]$ ./bug
In main:
foo's context should be:
sp 0xbfffe5f0
size 4096
In foo:
context is:
sp (nil)
size 0
That differs from the output of the same program running on
a Solaris 9 machine.
[marques@kant sample]$ ./bug
In main:
foo's context should be:
sp ffbfea44
size 4096
In foo:
context is:
sp ffbfea44
size 4096
I'm not certain of the precise semantics of this call, but the NULL and 0 values
seem to disagree with the behavior as described in the GNU C Library Manual,
http://www.gnu.org/software/libc/manual/html_node/System-V-contexts.html#index-getcontext-2785
where it states:
"The getcontext function initializes the variable pointed to by ucp with the
context of the calling thread.
The context contains the content of the registers, the signal mask, and the
current stack."
>>How-To-Repeat:
Here is the program used to produce the above output. It was compiled with gcc
with no
special flags, opts, etc.
#include <stdio.h>
#include <ucontext.h>
ucontext_t temp;
ucontext_t main_context;
ucontext_t helper_context;
int foo(int id)
{
getcontext(&temp);
printf("\n\n In foo: \n");
printf(" context is: \n");
printf(" sp %p \n", temp.uc_stack.ss_sp);
printf(" size %d \n", temp.uc_stack.ss_size);
return 0;
}
int main()
{
char helper_stack[4096];
getcontext(&helper_context);
helper_context.uc_link = &main_context;
helper_context.uc_stack.ss_sp = helper_stack;
helper_context.uc_stack.ss_size = 4096;
makecontext(&helper_context, (void (*) (void)) foo, 1, 1);
printf(" In main: \n");
printf(" foo's context should be: \n");
printf(" sp %p \n", helper_context.uc_stack.ss_sp);
printf(" size %d \n", helper_context.uc_stack.ss_size);
swapcontext(&main_context, &helper_context);
return 0;
}
>>Fix:
--
Summary: getcontext() not setting arg's uc_stack correctly
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: gotom at debian dot or dot jp
ReportedBy: marques at cs dot cornell dot edu
CC: glibc-bugs at sources dot redhat dot com
GCC build triplet: libc-2.3.2
GCC host triplet: i386-redhat-linux-gnu
GCC target triplet: Linux c3linux.u.cs.cornell.edu 2.4.20-31.9 #1 Tue Apr 13
18:04:2
http://sources.redhat.com/bugzilla/show_bug.cgi?id=759
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.