Opened 8 years ago

Closed 8 years ago

#10237 closed Bugs (invalid)

[windows] condition_variable wait infinitly

Reported by: anonymous Owned by: viboes
Milestone: Component: thread
Version: Boost 1.55.0 Severity: Problem
Keywords: condition_variable wait Cc:

Description

Os:any windows

The app will wait infinitly when app code like below:

thread A

cout<<"Start to wait B..."<<endl;
con.wait(lock);
cout<<"Run A..."<<endl;
boost::this_thread::sleep(boost::posix_time::seconds(1));//do something
cout<<"Start to notify B..."<<endl;
con.notify_one();
cout<<"End to notify B..."<<endl;

thread B

boost::this_thread::sleep(boost::posix_time::seconds(2));//do something
con.notify_one();
boost::this_thread::sleep(boost::posix_time::seconds(2));
cout<<"Start to wait A..."<<endl;
con.wait(lock);//thread A will call notify_one before this line
cout<<"Run again A..."<<endl;

cause:\boost\thread\win32\condition_variable.hpp line 261

if(detail::interlocked_read_acquire(&total_count))

The code will get read acquire count,and skip release when read acquire count is zero

Change History (6)

comment:1 by anonymous, 8 years ago

Summary: condition_variablecondition_variable wait infinitly

comment:2 by viboes, 8 years ago

Owner: changed from Anthony Williams to viboes
Status: newassigned

comment:3 by viboes, 8 years ago

Summary: condition_variable wait infinitly[windows] condition_variable wait infinitly

comment:4 by viboes, 8 years ago

The current implementation of interlocked_read_acquire uses InterlockedCompareExchange.

I don't know well the windows interface, but why do you think that need to release? Have you a working example that fall in the race condition you expose?

comment:5 by viboes, 8 years ago

Milestone: To Be DeterminedBoost 1.57.0

comment:6 by viboes, 8 years ago

Milestone: Boost 1.57.0
Resolution: invalid
Status: assignedclosed

Please reopen it when you have a test case or a deeper analysis.

Note: See TracTickets for help on using tickets.