-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<condition_variable>
: condition_variable_any::wait_for
returns cv_status::timeout
when the elapsed time is shorter than requested
#4723
Comments
Lines 187 to 198 in e36ee6c
CC @AlexGuteniev. |
Why? It rounds the parameter passed to wait, so would err on the other side. |
Oh, I see. Probably I was wrong then. Can we reproduce the error with |
This looks like an STL bug that wasn't fixed by #4457 (despite how I Changelogged it, oopsy). According to WG21-N4981 [thread.condvarany.wait]/11:
STL/stl/inc/condition_variable Lines 117 to 126 in e36ee6c
STL/stl/inc/condition_variable Lines 227 to 233 in e36ee6c
Lines 44 to 54 in e36ee6c
We're calling We need to audit this area again (both |
@AlexGuteniev @frederick-vs-ja @StephanTLavavej @cpplearner I would like to collaborate on this, requested in Discord chat space too :) |
Actually it is not a system clock, it is a steady clock, but an imprecise steady clock not matching |
condition_variable_any::wait_for
returns cv_status::timeout
when the elapsed time is shorter than requested<condition_variable>
: condition_variable_any::wait_for
returns cv_status::timeout
when the elapsed time is shorter than requested
<condition_variable>
: condition_variable_any::wait_for
returns cv_status::timeout
when the elapsed time is shorter than requested<condition_variable>
: condition_variable_any::wait_for
returns cv_status::timeout
when the elapsed time is shorter than requested
Adding the following: #include <Windows.h>
#pragma comment(lib, "Winmm.lib")
...
int main(int, char**) {
auto p = timeBeginPeriod(1);
...
timeEndPeriod(p);
return 0;
} Makes the bug more reproducible |
Describe the bug
Revealed by libc++ test
test/std/thread/thread.condition/thread.condition.condvarany/wait_for.pass.cpp
.[thread.condvarany.wait]/13:
But MSVC STL's
condition_variable_any::wait_for
sometimes returnscv_status::timeout
even though the elapsed time (measured byhigh_resolution_clock
) is shorter than the requested timeout.Command-line test case
(You might need to execute the program several times to see the output.)
Expected behavior
.\test-condvarany.exe
should consistently produce no outputSTL version
The text was updated successfully, but these errors were encountered: