[libc++] Patch to fix futures unit test hangs on Linux

Hi -

I've recently been trying to get the mainline libc++ unit tests to
pass on Linux (Ubuntu 12.04 x86_64). The following tests

    libc++ :: thread/futures/futures.promise/alloc_ctor.pass.cpp
    libc++ :: thread/futures/futures.promise/move_assign.pass.cpp
    libc++ :: thread/futures/futures.promise/move_ctor.pass.cpp
    libc++ :: thread/futures/futures.shared_future/dtor.pass.cpp
    libc++ :: thread/futures/futures.unique_future/dtor.pass.cpp

were hanging indefinitely, with stacks like this:

#0 __lll_lock_wait_private () at
../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:93
#1 0x00007ffff7bc8bf7 in _L_lock_21 () from
/lib/x86_64-linux-gnu/libpthread.so.0
#2 0x00007ffff7bc8a6e in __pthread_cond_destroy (cond=0x40e050) at
pthread_cond_destroy.c:33
#3 0x00007ffff7fcefdb in std::__1::__assoc_sub_state::~__assoc_sub_state() ()
   from libc++.so.1
#4 0x00000000004027df in
std::__1::__assoc_sub_state_alloc<test_allocator<void>

::__on_zero_shared() ()

#5 0x00007ffff7f9529d in std::__1::__shared_count::__release_shared() ()
   from libc++.so.1
#6 0x00007ffff7fce93d in std::__1::promise<void>::~promise() ()
   from libc++.so.1
#7 0x0000000000401a88 in main ()

I noticed that in __assoc_sub_state_alloc<Alloc>::__on_zero_shared
there are actually two explicit calls to the destructor for 'this',
which seems wrong to me. After arbitrarily removing the call to
this->~base(), leaving just the one call to
this->~assoc_sub_state_alloc(), the tests listed above no longer hang
in my environment. I've attached that edit as a patch.

Thanks,
Andrew

sub_state_alloc.patch (427 Bytes)

Thanks Andrew! Your fix looks right on to me. I searched <future> for similar bugs but did not find any. Committed revision 157476.

Howard