https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118093

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Jonathan Wakely
<r...@gcc.gnu.org>:

https://gcc.gnu.org/g:1a8d20cd803b1818378e06b2a437debd3cc5176f

commit r13-9536-g1a8d20cd803b1818378e06b2a437debd3cc5176f
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Tue Dec 17 21:32:19 2024 +0000

    libstdc++: Fix std::future::wait_until for subsecond negative times
[PR118093]

    The current check for negative times (i.e. before the epoch) only checks
    for a negative number of seconds. For a time 1ms before the epoch the
    seconds part will be zero, but the futex syscall will still fail with an
    EINVAL error. Extend the check to handle this case.

    This change adds a redundant check in the headers too, so that we avoid
    even calling into the library for negative times. Both checks can be
    marked [[unlikely]]. The check in the headers avoids the cost of
    splitting the time into seconds and nanoseconds and then making a PLT
    call. The check inside the library matches where we were checking
    already, and fixes existing binaries that were compiled against older
    headers but use a newer libstdc++.so.6 at runtime.

    libstdc++-v3/ChangeLog:

            PR libstdc++/118093
            * include/bits/atomic_futex.h (_M_load_and_test_until_impl):
            Return false for times before the epoch.
            * src/c++11/futex.cc (_M_futex_wait_until): Extend check for
            negative times to check for subsecond times. Add unlikely
            attribute.
            (_M_futex_wait_until_steady): Likewise.
            * testsuite/30_threads/future/members/118093.cc: New test.

    (cherry picked from commit 8ade3c3ea77e166f2873fb7ae57f9690e2b8d0e0)
  • [Bug libstdc++/118093] std::fut... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to