This is the mail archive of the
glibc-bugs@sources.redhat.com
mailing list for the glibc project.
[Bug nptl/881] New: NPTL threads inherit alternate signal stack
- From: "michael dot kerrisk at gmx dot net" <sourceware-bugzilla at sources dot redhat dot com>
- To: glibc-bugs at sources dot redhat dot com
- Date: 27 Apr 2005 16:03:53 -0000
- Subject: [Bug nptl/881] New: NPTL threads inherit alternate signal stack
- Reply-to: sourceware-bugzilla at sources dot redhat dot com
The POSIX.1-2003 specification of pthread_create() says:
The alternate signal stack shall not be inherited
However, as the simple program below shows, the settings
established by sigaltstack() are inherited in the new thread
created by pthread_create(). When I run this program on one
x86 system I see:
$ ./a.out
main: Checked alternate stack is at: 0x804a008, 0, 8192
Thread: Initial alternate stack is at: 0x804a008, 0, 8192
I notice that Solaris 8 seems to behave the same as Linux/glibc,
but that Tru64 5.1B does what I would expect, showing the fields
of the sigstack structure as being zeroed in the thread (i.e.,
the last line of output above).
(Assuming I've interpreted the standard correctly...) Is this
fixable? Or otherwise, is it documented somewhere?.
Cheers,
Michael
/* thread_sigaltstack_simple.c */
#include <pthread.h>
#include <signal.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#define errExit(msg) { perror(msg); exit(EXIT_FAILURE); }
#define errExitEN(en, msg) { errno = en; perror(msg); \
exit(EXIT_FAILURE); }
static void *
threadFunc1(void *arg)
{
stack_t os;
if (sigaltstack(NULL, &os) == -1) errExit("sigaltstack");
printf("Thread: Initial alternate stack is at: %10p, %d, %ld\n",
os.ss_sp, os.ss_flags, (long) os.ss_size);
return NULL;
}
int
main(int argc, char *argv[])
{
pthread_t t1;
int s;
stack_t sigstack, os;
sigstack.ss_sp = malloc(SIGSTKSZ);
if (sigstack.ss_sp == NULL) errExit("malloc");
sigstack.ss_size = SIGSTKSZ;
sigstack.ss_flags = 0;
if (sigaltstack(&sigstack, NULL) == -1) errExit("sigaltstack");
if (sigaltstack(NULL, &os) == -1) errExit("sigaltstack");
printf("main: Checked alternate stack is at: %10p, %d, %ld\n",
os.ss_sp, os.ss_flags, (long) os.ss_size);
s = pthread_create(&t1, NULL, threadFunc1, (void *) 1);
if (s != 0) errExitEN(s, "pthread_create");
s = pthread_join(t1, NULL);
if (s != 0) errExitEN(s, "pthread_join");
exit(EXIT_SUCCESS);
}
--
Summary: NPTL threads inherit alternate signal stack
Product: glibc
Version: 2.3.4
Status: NEW
Severity: normal
Priority: P2
Component: nptl
AssignedTo: drepper at redhat dot com
ReportedBy: michael dot kerrisk at gmx dot net
CC: glibc-bugs at sources dot redhat dot com
http://sources.redhat.com/bugzilla/show_bug.cgi?id=881
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.