[LCP]FW: pthread_mutex_lock call hangs

Ajay Bansal Ajay_Bansal@infosys.com
Wed Mar 12 07:34:00 GMT 2003

Hi All
I have been able to solve the problem. But the root cause is still not
clear. Following is the scenario in the code.
I have a class CriticalSection which is being used in the class for
Following is the class
typedef struct _critsection {
    pthread_t     Owner;
    int       LockDepth;
    pthread_mutex_t Lock;
typedef class CriticalSection {
    CriticalSection() {  CriticalSectionLock.Owner = 0;
CriticalSectionLock.Lock = GenericMutexInitializer;      }
    int Lock() { return EnterCriticalSection(&CriticalSectionLock); }
//for locking the mutex
    void Unlock() { LeaveCriticalSection(&CriticalSectionLock); } //for
unlocking the mutex
    CRITICAL_SECTION CriticalSectionLock;
My code uses the above class as
class myClass {
CCriticalSection myLock;
void Lock(){myLock.Lock();}
myClass *myObj = new myObj();
Now in debug mode, initializer of "CriticalSection" is not being called.
& then locking fails. As soon as I change  the name of class
"CriticalSection" to some other name.. say "ACriticalSection". code
works fine.
what can this mean?? & why this behaviour only in the debug mode?????
-----Original Message-----
From: Vincent Penquerc'h [mailto:Vincent.Penquerch@artworks.co.uk] 
Sent: Friday, March 07, 2003 11:03 PM
To: 'linuxcprogramming@lists.linux.org.au'
Subject: RE: [LCP]FW: pthread_mutex_lock call hangs

> > Only difference between two build is of "-g" flag. There is 

And about the link ? Are different libs being linked against ? 
Sorry to state the obvious. 
Only think I can think of is timing issues. Debug info in the exe 
could *maybe* cause more disk load at startup, which could influence 
the thread timing. Just a shot in the dark, really. 
To make sure it's not something else that -g, strip your program 
compiled with -g, and test it. Stripped program should be the same 
as the release one. 

(Sorry about the HTML, it's converted after my mailer sends plain 

Vincent Penquerc'h 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20030312/65ecbb77/attachment.htm>

More information about the Gcc-help mailing list