[Bug libstdc++/58038] std::this_thread::sleep_until can cause inifinite sleep

m at matthewlai dot ca gcc-bugzilla@gcc.gnu.org
Fri Feb 28 07:38:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58038

Matthew Lai <m at matthewlai dot ca> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |m at matthewlai dot ca

--- Comment #7 from Matthew Lai <m at matthewlai dot ca> ---
I also encountered this bug trying to use std::this_thread::sleep_until() for
video frame spacing (so the sleeps are very short, and sometimes become
negative).

Without this fix there is no way to safely use std::this_thread::sleep_until(),
because even if the caller checks for negative sleep durations, there is always
the chance that the thread gets preempted after entering the function, and
before it checks the current time. Theoretically speaking any amount of time
can elapse between those 2 points.



More information about the Gcc-bugs mailing list