Opened 9 years ago

Closed 8 years ago

#9558 closed Bugs (fixed)

future continuations unit test hangs in get()/pthread_cond_wait() on Mac 10.7/32-bit/x86/darwin-4.2.1

Reported by: Monty Brandenberg <mcbinc@…> Owned by: viboes
Milestone: Boost 1.57.0 Component: thread
Version: Boost 1.55.0 Severity: Problem
Keywords: future continuations Cc:

Description

I'm building 32- and 64-bit versions of thread on Mac and validating the result with the unit tests. Test 'ex_future_then_lib' hangs consistently in pthread_cond_wait() in a 32-bit build, all tests succeed in 64-bit builds.

Platform: Mac 10.7.5, Xcode 4.3.3, darwin-4.2.1.

Successful build and test (64-bit):

./bjam toolset=darwin variant=debug --layout=tagged --with-thread  -sNO_BZIP2=1 stage
cd libs/thread/test/
../../../bjam toolset=darwin variant=debug --layout=tagged --with-thread  -sNO_BZIP2=1 -a -q -d2 -d+4

Hanging build and test (32-bit):

./bjam toolset=darwin variant=debug address-model=32 architecture=x86 --layout=tagged --with-thread  -sNO_BZIP2=1 stage
cd libs/thread/test/
../../../bjam toolset=darwin variant=debug address-model=32 architecture=x86 --layout=tagged --with-thread  -sNO_BZIP2=1 -a -q -d2 -d+4

Stacktrace from hung unit test:

#0  0x9c19c83e in __psynch_cvwait ()
#1  0x93bf3e21 in _pthread_cond_wait ()
#2  0x93ba442c in pthread_cond_wait$UNIX2003 ()
#3  0x00025a0b in boost::condition_variable::wait (this=0x34b16c, m=@0xbffff750) at condition_variable.hpp:73
#4  0x00025bf2 in boost::detail::shared_state_base::wait_internal (this=0x34b120, lk=@0xbffff750, rethrow=true)
    at future.hpp:327
#5  0x00025cf7 in boost::detail::shared_state_base::wait (this=0x34b120, rethrow=true) at future.hpp:346
#6  0x00031b2b in boost::detail::future_async_shared_state_base<int>::wait (this=0x34b120, rethrow=true)
    at future.hpp:845
#7  0x00024c05 in boost::detail::shared_state<int>::get (this=0x34b120) at future.hpp:666
#8  0x000248ca in boost::future<int>::get (this=0xbffff978) at future.hpp:1555
#9  0x000021b3 in main () at future_then.cpp:69

Extent of output at time of hang (appears not to have run P2):

Starting program: /Users/monty/3P/3p-boost-update/boost/bin.v2/libs/thread/test/ex_future_then_lib.test/darwin-4.2.1/debug/address-model-32/architecture-x86/threading-multi/ex_future_then_lib 
Reading symbols for shared libraries ++......................... done
0xac7e22c0 - ../example/future_then.cpp[63] <MAIN
0xb0081000 - ../example/future_then.cpp[18] P1

That's the extent of the bug. In addition, there's some sloppy return value coding in the example code:

../example/future_then.cpp: In function ‘int p2s(boost::shared_future<int>)’:
../example/future_then.cpp:59: warning: control reaches end of non-void function
../example/future_then.cpp: In function ‘int p2(boost::future<int>)’:
../example/future_then.cpp:40: warning: control reaches end of non-void function

Change History (11)

comment:1 by Monty Brandenberg <mcbinc@…>, 9 years ago

As a workaround, unit tests can be passed by disabling all the boost::future related features:

../../../bjam toolset=darwin variant=debug address-model=32 architecture=x86 --layout=tagged --with-thread  -sNO_BZIP2=1 -a -q -d2 -d+4 cxxflags="-DBOOST_THREAD_DONT_PROVIDE_FUTURE_CONTINUATION -DBOOST_THREAD_DONT_PROVIDE_FUTURE_CTOR_ALLOCATORS -DBOOST_THREAD_DONT_PROVIDE_FUTURE_CONTINUATION -DBOOST_THREAD_DONT_PROVIDE_FUTURE_UNWRAP -DBOOST_THREAD_DONT_PROVIDE_FUTURE_INVALID_AFTER_GET"

comment:2 by viboes, 9 years ago

Please, could you check if this change-set https://github.com/boostorg/thread/commit/cb845f19e4a975fc95e8b10c096280085d24eb03 improves the situation? Note that it restrict the use of the variadic versions. It works for all the compiler for which BOOST_NO_CXX11_DECLTYPE_N3276 is defined.

comment:3 by viboes, 9 years ago

Owner: changed from Anthony Williams to viboes
Status: newassigned

comment:4 by Monty Brandenberg <mcbinc@…>, 9 years ago

I will check the changeset. It may be a day or two before I can get to it...

in reply to:  4 ; comment:5 by viboes, 9 years ago

Replying to Monty Brandenberg <mcbinc@…>:

I will check the changeset. It may be a day or two before I can get to it...

It seems that there are yet some troubles. See http://www.boost.org/development/tests/develop/developer/thread.html.

in reply to:  5 comment:6 by viboes, 9 years ago

Replying to viboes:

Replying to Monty Brandenberg <mcbinc@…>:

I will check the changeset. It may be a day or two before I can get to it...

It seems that there are yet some troubles. See http://www.boost.org/development/tests/develop/developer/thread.html.

The regression test pass now. It seems there were some issues with the git files update on some regression testers. Please let me know if the develop branch fixes your issue.

Last edited 9 years ago by viboes (previous) (diff)

comment:7 by viboes, 9 years ago

Moved to problem as this doesn't prevent the use of the library. .then() is experimental.

comment:8 by viboes, 9 years ago

Severity: ShowstopperProblem

comment:9 by viboes, 8 years ago

data race condition identified in #10478 Data race in boost/thread/future.hpp

comment:11 by viboes, 8 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.