From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: ffc1e,fe0b10dbbe6f86ef X-Google-Attributes: gidffc1e,public X-Google-Thread: 1164f8,fe0b10dbbe6f86ef X-Google-Attributes: gid1164f8,public From: Lawrence MacIntyre Subject: Re: DEC C++ compiler problem with pthread_cond_timedwait Date: 1997/06/23 Message-ID: <33AEA794.41C6@nautique.epm.ornl.gov>#1/1 X-Deja-AN: 252045584 References: <01bc7dcd$031affc0$910101c0@zippy> To: Todd Murray Organization: Oak Ridge National Laboratory Newsgroups: comp.programming.threads,comp.sys.dec Todd Murray wrote: > > 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. Todd: You may have a compiler bug, but you also may have bad code. When you compile with the debugger, you add a lot of code into your image. If you have some place where you overflow a buffer, it may be that you overflow into a place where you have no further interest, and you don't find out. However, with the additional debugger code, you may be using the overflowed memory now. In every case where I've had this type of problem, I've traced it to buffer overflow (or writing to freed memory, or some similar thing). Good luck finding the problem. -- Lawrence ~ ------------------------------------------------------------------------ Lawrence MacIntyre Oak Ridge National Laboratory 423.574.8696 lpz@ornl.gov http://www.epm.ornl.gov/~lpz lpz@nautique.epm.ornl.gov