Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: Lawrence MacIntyre <lpz@nautique.epm.ornl.gov>
To: Todd Murray <tam@nospam.visi.com>
Subject: Re: DEC C++ compiler problem with pthread_cond_timedwait
Date: 1997/06/23	[thread overview]
Message-ID: <33AEA794.41C6@nautique.epm.ornl.gov> (raw)
In-Reply-To: 01bc7dcd$031affc0$910101c0@zippy


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



      reply	other threads:[~1997-06-23  4:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-06-20  4:00 DEC C++ compiler problem with pthread_cond_timedwait Todd Murray
1997-06-23  4:00 ` Lawrence MacIntyre [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox