Boost logo

Boost Users :

Subject: [Boost-users] [Interprocess] Deadlock when using interprocess_semaphore
From: Derek Kivi (derek.kivi_at_[hidden])
Date: 2009-03-04 16:35:14


We are seeing a deadlock when making use of the interprocess_semaphore.

In our case we have two running threads where the first thread is stuck
waiting at a timed_wait() call while the second thread is stuck at a
post() call.

Also, a symptom we are seeing is that the lock value is set to 1 before
both threads try to acquire the lock -- we think this is why the threads
get stuck in the lock calls.

We are running 1.36 at the moment. Have there been any fixes in 1.37 or
1.38 that might help us to avoid this problem?

Thanks,
Derek

Here is what the stacks for each thread look like from the Visual C++
debugger:

Thread1
-------
Singletons.dll!boost::interprocess::scoped_lock<boost::interprocess::int
erprocess_mutex>::scoped_lock<boost::interprocess::interprocess_mutex>(b
oost::interprocess::interprocess_mutex & m={...}) Line 78 + 0x27 bytes
C++
Singletons.dll!boost::interprocess::interprocess_semaphore::timed_wait(c
onst boost::posix_time::ptime & abs_time={...}) Line 55 + 0xc bytes
C++
Singletons.dll!QSemaphoreImpl::Wait(const unsigned long
timeoutMilliseconds=1000) Line 62 + 0xf bytes C++
Singletons.dll!QSemaphore::Wait(const unsigned long
timeoutMilliseconds=1000) Line 24 C++
Singletons.dll!QUtilityThread::DefaultAction(quic::HpcSharedPtr<IThread,
std::allocator> data={...}) Line 105 + 0x18 bytes C++

Thread2
-------
ntdll.dll!7c90e4f4()
[Frames below may be incorrect and/or missing, no symbols loaded for
ntdll.dll]
ntdll.dll!7c90d1fc()
kernel32.dll!7c8023f1()
kernel32.dll!7c802455()
Singletons.dll!boost::interprocess::winapi::sched_yield() Line 281 +
0xe bytes C++
Singletons.dll!boost::interprocess::detail::thread_yield() Line 51 +
0x8 bytes C++
Singletons.dll!boost::interprocess::interprocess_mutex::lock() Line 40
C++
Singletons.dll!boost::interprocess::interprocess_condition::notify(unsig
ned long command=1) Line 50 C++
Singletons.dll!boost::interprocess::interprocess_condition::notify_one()
Line 33 C++
Singletons.dll!boost::interprocess::interprocess_semaphore::post() Line
31 C++
Singletons.dll!QSemaphoreImpl::Post() Line 45 C++
Singletons.dll!QSemaphore::Post() Line 18 C++
Singletons.dll!QUtilityThread::RegisterTask(IBackgroundTask *
pBackgroundTask=0x01002660) Line 54 C++

-- 
Derek Kivi
Senior Software Developer
QuIC Financial Technologies Inc. 
Office: +1 403 210 8282 
Mobile: +1 403 863 5204 
derek.kivi_at_[hidden]
Risk. Managed.
www.quic.com 
Confidentiality Notice: The information transmitted is intended only for the person(s) or entity(ies) to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination, or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this email in error, please contact the sender and delete the email and any related material from any computer.
ver. QuIC 0707

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net