Mysterious SIGALRM's using pthreads & sockets
807575Aug 31 2000 — edited Aug 9 2001I'm trying to port a C++ application to Solaris 8/Sparc using the new
Forte 6 development tools/libraries and a new Sun E250 Server.
I'm using various pthreads components (threads/mutexes/conditions/signal
handling), as well as your standard socket programming calls (socket/bind/
accept/etc.). I've managed to get all the code compiling fine without
too much trouble (save the insane list of options required for what I'd
consider pretty standard code). All the code seems to be working now
with the exception of a multithreaded program.
The program starts out with two threads working as a simplified web
server and as an asynchronous signal handler, and then upon a form
submission starts up a couple more threads: a producer and consumer,
and a separate thread performing a task at a fixed time interval.
When my program starts up, the two threads perform wonderfully. But
once I start up the others, the program runs for a about 3-5 seconds
and then receives an alarm signal (SIGALRM). The signal causes
everything to shutdown and exit (and I've even tried blocking it in
every way imaginable -- at the thread and process levels).
I've searched high and low and found no information on what might be
causing this. I tried a bunch of different compiler options, from:
(compile) CC -mt -instances=static -g -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT
(link) CC -mt -lpthread -lposix4 -lsocket -lnsl -library=%none,Cstd,Crun,iostream
to all kinds of combinations of the POSIX flags (additionally, POSIXPER_PROCESS_TIMERS and POSIXC_SOURCE), and the Solaris native
threading flags (-lthread, -lrt, -D_REENTRANT, etc.). The POSIXC_SOURCE
define I found mentioned in documentation somewhere, but unfortunately
Forte's header files are broken so as to break everything when you
actually try to use it.
I've also tried using forte's graphical debugger -- stepping through
instruction-by-instruction, and it doesn't appear to have any
correlation to the code; it's happening at random locations. I've
even tried cutting out the code for the signal handling and for the fixed-interval timer to narrow it down, but no luck. I'm starting
to think there must be a bug in Solaris' pthreads implementation.
I guess my next step is to break down and replace my pthreads code
with Solaris native code, but I'm hoping there's a saviour out there
for me... Pleeeaseee save me from having to do that ;)
Thanks,
Mike