[committed] libstdc++: Optimise std::future::wait_for and fix futex polling

Jonathan Wakely jwakely@redhat.com
Fri Nov 13 19:16:20 GMT 2020


>Backporting the change to gcc-10 revealed an overflow bug in the
>existing code, resulting in blocking for years when given an absolute
>timeout in the distant past. There's still a similar bug in the new
>code (using futexes with absolute timeouts against clocks) where a
>large chrono::seconds value can overflow and produce an incorrect
>tv_sec value. Apart from the overflow itself being UB, the result in
>that case is just a spurious wakeup (the call says it timed out when
>it didn't reach the specified time). That should still be fixed, but
>I'll do it separately.

And here's the separate fix for that other overflow. In fact it
doesn't just produce spurious wakeups. It either spins forever
(instead of sleeping gently) or incorrectly reports a timeout when it
should keep blocking. Either way, it's fixed now.

Tested x86_64-linux && powerpc64le-linux. Committed to trunk.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 5726 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20201113/6f55e38e/attachment.bin>


More information about the Libstdc++ mailing list