Solved

WaitForSingleObject return WAIT_ABANDONED, and no thread own it

Posted on 2001-09-03
11
2,922 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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
 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

739 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