deadlock - Critical section negative lock count -


I'm debugging a deadlock issue and call the stack show that threads are waiting on some events.

Code synchronization is using the important section as the primitive I think there is some problem here. Apart from this, the debugger is pointing to an important section which is owned by another thread, but the lock number is 2 according to my understanding of calculation> 0 means that the important segment is locked by one or more threads has been done.

There is a possibility that I am looking at the right section that can be a criminal in Deadlock.

I say the negative lock in a key segment in the scenario Might be possible? If you are talking about the CCriticalSection class in MFC, I think that you are looking at the right section. I have noticed that lock count of important segment can be negative if the lock () function is less than the number of calls unlock () calls I have found that it usually occurs in the following type of code:

  void f () {CSingleLock lock (& ​​amp; m_synchronizer, TRUE); // some logic here m_synchronizer.unlock (); } This code is absolutely safe at first glance. However, note that I am using the unlock () method of secrecy science instead of the unlocking () method of the simulation lock. Now what happens when the function turns out, in its block, CSingleLock again calls the unlock key (important) of the block and its lock becomes negative, after which the application will be in poor shape and strange things should start. If you are using MFC important sections, then check for these types of problems. 


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -