aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family/c-cppbuiltin.c
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2020-11-13 19:11:02 +0000
committerJonathan Wakely <jwakely@redhat.com>2020-11-13 19:11:07 +0000
commit91004436daaf8d54daa467908d1b634a1a352707 (patch)
tree2f449da8e4fab14f7f038e609453b7392393e863 /gcc/c-family/c-cppbuiltin.c
parent500e7efee91cc66f91f993f53039983f131f7075 (diff)
downloadgcc-91004436daaf8d54daa467908d1b634a1a352707.zip
gcc-91004436daaf8d54daa467908d1b634a1a352707.tar.gz
gcc-91004436daaf8d54daa467908d1b634a1a352707.tar.bz2
libstdc++: Avoid more 32-bit time_t overflows in futex calls
This fixes another overflow in code converting a std::chrono::seconds duration to a time_t. This time in the new code using a futex wait with an absolute timeout (so this one doesn't need to be backported to the release branches). A timeout after the epochalypse would overflow the tv_sec field, producing an incorrect value. If that incorrect value happened to be negative, the syscall would return with EINVAL and then the caller would keep retrying, spinning until the timeout was reached. If the value happened to be positive, we would wake up too soon and incorrectly report a timeout libstdc++-v3/ChangeLog: * src/c++11/futex.cc (relative_timespec): Add [[unlikely]] attributes. (__atomic_futex_unsigned_base::_M_futex_wait_until) (__atomic_futex_unsigned_base::_M_futex_wait_until_steady): Check for overflow. * testsuite/30_threads/future/members/wait_until_overflow.cc: New test.
Diffstat (limited to 'gcc/c-family/c-cppbuiltin.c')
0 files changed, 0 insertions, 0 deletions