Comments (7)
We're calling
GetTickCount64()
which is the system clock.
Actually it is not a system clock, it is a steady clock, but an imprecise steady clock not matching std::steady_clock
.
from stl.
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:
template<class Lock, class Rep, class Period> cv_status wait_for(Lock& lock, const chrono::duration<Rep, Period>& rel_time);Effects: Equivalent to:
return wait_until(lock, chrono::steady_clock::now() + rel_time);
condition_variable_any::wait_for
should use the steady_clock
. But we don't do that:
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 GetTickCount64()
which is the system clock.
We need to audit this area again (both condition_variable
and condition_variable_any
) and make sure we Do What The Standard SaysTM.
from stl.
The round-up in _Clamped_rel_time_ms_count
(introduced in #4457) looks like the reason. 249758μs would be turned into 250ms here.
Lines 187 to 198 in e36ee6c
CC @AlexGuteniev.
from stl.
The round-up in
_Clamped_rel_time_ms_count
(introduced in #4457) looks like the reason
Why? It rounds the parameter passed to wait, so would err on the other side.
from stl.
The round-up in
_Clamped_rel_time_ms_count
(introduced in #4457) looks like the reasonWhy? 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 SleepConditionVariableSRW
? If so, we may need to work around it.
from stl.
@AlexGuteniev @frederick-vs-ja @StephanTLavavej @cpplearner I would like to collaborate on this, requested in Discord chat space too :)
from stl.
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
from stl.
Related Issues (20)
- `<xutility>`: Use addition and multiplication overflow check MSVC intrinsics like `_add_overflow_i8`, `_mul_overflow_i16`, and `_mul_full_overflow_i8` HOT 3
- `<execution>`: Should threadpool callback priority be influenced by parent thread priority? HOT 9
- Performance improvement about std::binary_semaphore::acquire HOT 5
- `<iomanip>`: `std::put_time` should copy unknown conversion specifiers instead of crash HOT 13
- Module STD: Redefinition Errors When Using import std Along With Other STL Includes HOT 7
- Standard Library Modules: error C2039: `'promise_type'`: is not a member of `'std::coroutine_traits<TestModule::FireAndForget>'` HOT 3
- `STL.natvis`: `move_iterator` visualizer should use `_Current`, not `current`
- `STL.natvis`: `ranges::view_interface` doesn't always have `size()`
- `STL.natvis`: The VS copy is outdated
- `README.md`: Update working draft revision to N4986
- xlocnum error C2065: 'PTRDIFF_MAX': undeclared identifier HOT 10
- `<type_traits>`: Logical operator traits with non-`bool_constant` arguments emit truncation warnings
- STL: `expected<any, T>` and its friends can break container iterator comparison HOT 2
- Shouldn't `std::exception::what()` be declared as `noexcept`? HOT 2
- <iostream>: std::cout with very low speed compared with printf HOT 3
- <stacktrace>: unloading fails of a dll that first obtained stacktrace
- Support for Win7 / Server 2008 R2 is DOOMED HOT 8
- <format>:How do I specialize the std::formatter with module HOT 1
- `<algorithm>`: `ranges::inplace_merge` doesn't seem to be able to utilize `ranges::upper_bound` HOT 8
- <execution>: Silent data loss in nested parallel file operations HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stl.