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

            Bug ID: 105673
           Summary: _M_futex_wait_until_steady() always falls back to old
                    syscall with FUTEX_WAIT operation even after
                    successful FUTEX_WAIT_BITSET
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vlad at solidsands dot nl
  Target Milestone: ---

We were doing coverage analysis of GNU libstdc++ library and noticed that in
the function _M_futex_wait_until_steady() (src/c++11/futex.cc) the second part
of the function is always executed even though the FUTEX_WAIT_BITSET syscall is
available on the system.

How to reproduce:
    auto f = std::async(std::launch::async, foo);
    const auto start{std::chrono::steady_clock::now()};
    auto status = f.wait_until(start + std::chrono::seconds{5});

We suspect the reason might be because the if statement on line 217 is missing
an else branch.
(https://gcc.gnu.org/git?p=gcc.git;a=blob;f=libstdc%2B%2B-v3/src/c%2B%2B11/futex.cc;h=4d56c286ec597c19e4dc20bfb0c82d03ee93da8d;hb=HEAD#l217)
The sibling function _M_futex_wait_until() does have an else branch for similar
if statement. Without the else branch if futex syscall was successful the
function still falls back to the alternative version and performs another futex
syscall.

Reply via email to