This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [v3] proposed fix for libstdc++/49204 causes abi_check failure


On 31 December 2011 17:33, Jonathan Wakely wrote:
> I want to commit the attached patch:
>
> ? ? ? ?PR libstdc++/49204
> ? ? ? ?* include/std/future (__future_base::_State_base::wait()): Call
> ? ? ? ?_M_complete_async instead of _M_run_deferred.
> ? ? ? ?(__future_base::_State_base::wait_for()): Call _M_has_deferred and
> ? ? ? ?return future_status.
> ? ? ? ?(__future_base::_State_base::wait_until()): Likewise.
> ? ? ? ?(__future_base::_State_base::_M_run_deferred()): Rename to ...
> ? ? ? ?(__future_base::_State_base::_M_complete_async()): This.
> ? ? ? ?(__future_base::_State_base::_M_has_deferred()): New.
> ? ? ? ?(__basic_future::wait_for(), __basic_future::wait_until()): Return
> ? ? ? ?future_status.
> ? ? ? ?(__future_base::_Deferred_state::_M_run_deferred()): Rename to ...
> ? ? ? ?(__future_base::_Deferred_state::_M_complete_async()): This.
> ? ? ? ?(__future_base::_Async_state::_M_join()): New.
> ? ? ? ?(__future_base::_Async_state::~_Async_state()): Call _M_join.
> ? ? ? ?(__future_base::_Async_state::_M_complete_async()): Likewise.
> ? ? ? ?* testsuite/30_threads/packaged_task/members/get_future.cc: Expect
> ? ? ? ?future_status return instead of bool.
> ? ? ? ?* testsuite/30_threads/shared_future/members/wait_until.cc: Likewise.
> ? ? ? ?* testsuite/30_threads/shared_future/members/wait_for.cc: Likewise.
> ? ? ? ?* testsuite/30_threads/future/members/wait_until.cc: Likewise.
> ? ? ? ?* testsuite/30_threads/future/members/wait_for.cc: Likewise.
> ? ? ? ?* testsuite/30_threads/promise/members/set_value2.cc: Likewise.
> ? ? ? ?* testsuite/30_threads/promise/members/set_value3.cc: Likewise.
> ? ? ? ?* testsuite/30_threads/promise/members/swap.cc: Likewise.
> ? ? ? ?* testsuite/30_threads/async/sync.cc: Likewise, and test 'deferred'
> ? ? ? ?status.
>
> But it causes this abi_check error:
>
> 1 incompatible symbols
> 0
> _ZTVNSt13__future_base11_State_baseE
> vtable for std::__future_base::_State_base
> version status: unversioned
> type: object
> type size: 48
> status: <default>
>
> ? ? ? ?incompatible sizes
> ? ? ? ?40
> ? ? ? ?48
>
> I've renamed _M_run_deferred to _M_complete_async but it has the same
> signature, semantics and position in the vtable. ?I've also added
> _M_has_deferred() at the end of the vtable, for an internal
> implementation type that users use directly or refer to. Is that OK
> and the testsuite can be adjusted to know about the new vtable size?

Here's a different, partial fix for PR 49204, changing the timed
waiting functions to return future_status, but not returning
future_status::deferred, as that requires the ABI change detailed
above.  This doesn't change the library ABI, but might still be too
big a change for 4.7 at this stage.

The ChangeLog is in several parts, as I did the work in stages. I'd
combine that properly if checking it in.

Define the key function non-inline, so it's only emitted in the
library not every file using std::async:

        PR libstdc++/49204
        * include/std/future (__future_base::_Async_state_common): Do not
        define destructor inline.
        * src/future.cc (__future_base::_Async_state_common): Define
        destructor, so key function is in the library.
        * config/abi/pre/gnu.ver: Add exports for ~_Async_state_common.

Meet the synchronisation requirement, as stated in the PR:

        PR libstdc++/49204
        * include/std/future (__future_base::_Async_state): Replace with
        _Async_state_common class for non-dependent functionality and
        _Async_state_impl class template for dependent functionality.
        (__future_base::_Async_state_common::_M_join): Serialize attempts to
        join thread.
        (__future_base::_Async_state_common::_M_run_deferred): Join.
        (__future_base::_Async_state::_M_do_run): Replace with lambda.

Make timed waiting functions return future_status:

        PR libstdc++/49204
        * include/std/future (__future_base::_State_base::wait()): Use lambda
        expression for predicate and remove redundant test.
        (__future_base::_State_base::wait_for()): Return future_status and
        use lambda expression for predicate.
        (__future_base::_State_base::wait_until()): Likewise.
        (__basic_future::wait_for(), __basic_future::wait_until()): Likewise.
        * testsuite/30_threads/packaged_task/members/get_future.cc: Expect
        future_status return instead of bool.
        * testsuite/30_threads/shared_future/members/wait_until.cc: Likewise.
        * testsuite/30_threads/shared_future/members/wait_for.cc: Likewise.
        * testsuite/30_threads/future/members/wait_until.cc: Likewise.
        * testsuite/30_threads/future/members/wait_for.cc: Likewise.
        * testsuite/30_threads/promise/members/set_value2.cc: Likewise.
        * testsuite/30_threads/promise/members/set_value3.cc: Likewise.
        * testsuite/30_threads/promise/members/swap.cc: Likewise.

The final piece, not included in this patch, would be adding the new
virtual function and renaming _M_run_deferred.

Attachment: 49204.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]