This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

problem with pthreads and sigaltstack


Hello.

I have a problem which is that my program
crashes when is simply linked with -lpthread.
My program uses the sigaltstack() and the
sigaction() to set up the signal handlers.
When the signal is received, the
pthread_sighandler() is invoked first, and
gets a SIGSEGV inside itself.
Looking into a linuxthreads sources, I can see
what happens:
pthread_sighandler() calls the thread_self(),
which returns an invalid pointer. It does this:
return (pthread_descr)(((unsigned long)sp | (STACK_SIZE-1))+1) - 1;
where the STACK_SIZE is defined to 2Mb, while
I set up the signal stack only to 64Kb with the
sigaltstack, so the pointer returned by the
thread_self() inside the sighandler is totally
bogus.

I don't know where the problem is. My current
workaround is to reserve 2Mb above the alt stack.
This allows my program to be linked with the
pthreads lib and the signal handlers are working
properly, but this is a definitely wrong way
because the pointer returned by thread_self()
doesn't point to any real data that pthread may
expect.

I am using the rather old glibc-2.2.4-19(RH) and
probably the problem will go away if I upgrade,
but I strongly suspect that I am doing something
wrong.
Any ideas where the real problem can be? Is it
the problem with pthreads and I have to upgrade,
or does it look more like a problem somewhere in
an app and it is doing something pthreads can't
tolerate?
I could probably use something like
pthread_attr_setstackaddr() and then pthread_create(),
but I only want to make my program to not crash
when it is linked with the libpthread. What is
the proper way of doing that?
My linux kernel is 2.4.22 and is running on an
AMD Athlon, if that matters.

Thanks for any help.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]