Solved

WaitForSingleObject return WAIT_ABANDONED, and no thread own it

Posted on 2001-09-03
11
2,880 Views
Last Modified: 2013-12-03
Hi,


The WaitForSingleObject return WAIT_ABANDONED.

The main thread owns it.
Two threads are using this mutex.  Each thread takes ownership on the
mutex  and release it for intermittently.
The first thread finishes its run(release the mutex) and exit with
code 0.
The second thread try to get the mutex.
The WAIT_ABANDONED return code recieved.  
If the test skipped the second thread get the mutex normally.

Can I skip this check?
What is the problem?

Thanks
0
Comment
Question by:Itay
  • 4
  • 2
  • 2
11 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 65 total points
ID: 6450552
Value
WAIT_ABANDONED

Meaning
The specified object is a mutex object that was not released by the thread that owned the mutex object before the owning thread terminated. Ownership of the mutex object is granted to the calling thread, and the mutex is set to nonsignaled.

It seems that your 2nd thread does not release the mutex before terminating...
0
 
LVL 7

Assisted Solution

by:peterchen092700
peterchen092700 earned 65 total points
ID: 6450591
i.e. the first thread did not release the mutex before terminating.
0
 

Author Comment

by:Itay
ID: 6450862
The two threads using object belongs to thread main.
This object has method that
1)    use WaitForSingleObject(handle, INFINIT)
2)    use Release(handle)

There is no chance that the mutex was not released.
0
 
LVL 7

Expert Comment

by:peterchen092700
ID: 6450891
neither threads nor mutexes belong to a thread. Threads belong to a process. Mutexes belong to the session (I guess), *Handles to* Mutexes belong to a process.

Add TRACEs to where you create, acquire and release the handles, and check the return value of WaitForXXX and ReleaseMutex.

Peter





0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 86

Expert Comment

by:jkr
ID: 6450902
>>Mutexes belong to the session

Mutexes are kerel objects, so they're just 'loaned'...
0
 

Author Comment

by:Itay
ID: 6450999
Sure,
:-)

The mutex in its current initilaization belongs to the process.

I traced the program, the return code from ReleaseMutex is 1.
Its okay as far as i know, it shouldn't be zero.

The return code from WaitForSingleObject is 0.
After the thread was destroyed, it is 128.


0
 
LVL 7

Expert Comment

by:peterchen092700
ID: 6451354
might sound a bit silly, but: did you count them? Remember that, for each successful wait for a mutex, there must be a releasemutex.

0
 
LVL 7

Expert Comment

by:peterchen092700
ID: 6467737
an abandoned mutex (i.e. thread acquired mutex, and teminated without releasing the mutex) is the *only* reason for WAIT_ABANDONED to be returned. So you might understand we expect yu to double-check this...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now