From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,fe0b10dbbe6f86ef,start X-Google-Attributes: gid1164f8,public X-Google-Thread: ffc1e,fe0b10dbbe6f86ef,start X-Google-Attributes: gidffc1e,public From: "Todd Murray" Subject: DEC C++ compiler problem with pthread_cond_timedwait Date: 1997/06/20 Message-ID: <01bc7dcd$031affc0$910101c0@zippy>#1/1 X-Deja-AN: 251441550 Organization: WaveFront Communications, Inc. Newsgroups: comp.programming.threads,comp.sys.dec I'm maintaining an application with multiple threads that communicates with a mainframe using the Brixton SNA Server library. I have a problem that I suspect is a bug with the DEC C++ compiler, but I'm not entirely sure yet and I'd like some advice. The program has four threads: the main thread, a thread that accepts requests from our other applications, a thread that organizes the requests depending on their mainframe destination [MvsInter], and a thread that talks with the Brixton software [AppcComm]. Thread #4's work used to be done in the main thread, but we needed the ability to communicate with multiple mainframes so I made it multithreaded. When this program is operating, thread #3 gets a request to send something to a specific mainframe. It locks a mutex and puts the request on thread #4's queue, then does a pthread_cond_timedwait to get the response. After thread #4 sends the request and gets a response from the mainframe, it signals thread #3's condition variable (using pthread_cond_signal, of course). This appears to work properly in our current version of the software, compiled using GNU g++. However, when I compile this using DEC C++ (for our upcoming version), thread #3's stack is apparently corrupted after I do the pthread_cond_timedwait call. I get a SEGV, and using the "where" command in ladebug tells me that I'm at location 0x3ff00000000 or something similar. It can't produce a reasonable stack trace for me because the stack is corrupted. This only happens when I compile the program debuggable (using -g); if I don't make it debuggable, I don't get a SEGV. I'm starting to suspect that this is caused by the DEC compiler's instructions that it inserts so you can view the state of a mutex or a condition variable from the debugger. I've tested this program for memory overwrites (using Insight) and it doesn't tell me that I have any memory corruption in the affected areas. I am using the DEC C++ compiler version 5.5-004 on Digital Unix 3.2D, with version 3.07 of the runtime libraries. Does anyone have any theories about why I only get this SEGV from compiling this debuggable using the DEC C++ compiler? (I would have tested this using a smaller test program, but I've been under the gun to get this project finished by today -- and I barely made it.) I know that the excuse "It's a compiler bug" has been used often enough before, but I can't think of any other reasons. :-) If you have any suggestions, E-mail me at tam@visi.com. Thanks.