| Commit message (Collapse) | Author | Age |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Instead of being only able to test the platform Waiter implementation,
this allows us to be able to test all Waiter implementations that
build on a specific platform.
A unittest is added that tests all implementations that work for the
platform, and allows us to check that the expected one is being used
by printing the name of the selected implementation.
PiperOrigin-RevId: 518072415
Change-Id: Ie9e6fcd9d8283b4038e6f4e68a304d2adcc04b19
|
|
|
|
|
|
|
| |
Windows tests often run in Emulation, and even with KVM we can still timeout.
PiperOrigin-RevId: 517192968
Change-Id: I3b4e435f8ac8ad1e7eab6f043c051fa75efed64b
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
monotonic clocks on Linux when the implementation uses futexes
After this change, when synchronization methods that wait are passed
an absl::Duration to limit the wait time, these methods will wait for
that interval, even if the system clock is changed (subject to any
limitations with how CLOCK_MONOTONIC keeps track of time). In other
words, an observer measuring the time with a stop watch will now see
the correct interval, even if the system clock is changed. Previously,
the duration was added to the current time, and methods would wait
until that time was reached on the possibly changed realtime system
clock.
The behavior of the synchronization methods that take an absl::Time is
unchanged. These methods always wait until the absolute point in time
is reached and respect changes to the system clock. In other words, an
observer will always see the timeout occur when a wall clock reaches
that time, even if the clock is manipulated externally.
Note: ABSL_PREDICT_FALSE was removed from the error case in Futex as
timeouts are handled by this case, and timeouts are part of normal
operation.
PiperOrigin-RevId: 516534869
Change-Id: Ib70b83e4be3f9e3f1727646975a21a1d30acb242
|
|
|
|
|
|
|
|
|
|
| |
timeouts, but when a relative timeout is provided, the timeout is an
absolute timeout against a steady clock (when possible). This allows
methods that return relative timeouts to automatically recompute the
remaining duration, for instance, on suprious wakeups.
PiperOrigin-RevId: 516304139
Change-Id: I7d739cb50dd749eba5dba7ac6c34d18dc53703ed
|
|
|
|
|
| |
PiperOrigin-RevId: 515427893
Change-Id: I89e8756fcf400459b0226d14785c6511ad3e380b
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
monotonic clocks on Linux when the implementation uses futexes
After this change, when synchronization methods that wait are passed
an absl::Duration to limit the wait time, these methods will wait for
that interval, even if the system clock is changed (subject to any
limitations with how CLOCK_MONOTONIC keeps track of time). In other
words, an observer measuring the time with a stop watch will now see
the correct interval, even if the system clock is changed. Previously,
the duration was added to the current time, and methods would wait
until that time was reached on the possibly changed realtime system
clock.
The behavior of the synchronization methods that take an absl::Time is
unchanged. These methods always wait until the absolute point in time
is reached and respect changes to the system clock. In other words, an
observer will always see the timeout occur when a wall clock reaches
that time, even if the clock is manipulated externally.
Note: ABSL_PREDICT_FALSE was removed from the error case in Futex as
timeouts are handled by this case, and timeouts are part of normal
operation.
PiperOrigin-RevId: 515043788
Change-Id: I151127b588065bd1316273f36d7c946545c2c892
|
|
|
|
|
| |
PiperOrigin-RevId: 512979517
Change-Id: I7fe38ed246e42e6f8eb322e15c3b299215163168
|
|
|
|
|
|
|
| |
large cycles.
PiperOrigin-RevId: 511536497
Change-Id: If70a1c72ef5f7cbb4a80100c4edff459373a5d55
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
monotonic clocks on Linux when the implementation uses futexes
After this change, when synchronization methods that wait are passed
an absl::Duration to limit the wait time, these methods will wait for
that interval, even if the system clock is changed (subject to any
limitations with how CLOCK_MONOTONIC keeps track of time). In other
words, an observer measuring the time with a stop watch will now see
the correct interval, even if the system clock is changed. Previously,
the duration was added to the current time, and methods would wait
until that time was reached on the possibly changed realtime system
clock.
The behavior of the synchronization methods that take an absl::Time is
unchanged. These methods always wait until the absolute point in time
is reached and respect changes to the system clock. In other words, an
observer will always see the timeout occur when a wall clock reaches
that time, even if the clock is manipulated externally.
Note: ABSL_PREDICT_FALSE was removed from the error case in Futex as
timeouts are handled by this case, and timeouts are part of normal
operation.
PiperOrigin-RevId: 510405347
Change-Id: I0b3ea390de97014cfa353079ae2e0c1c637aca69
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
std::chrono methods used by std::condition_variable.
A followup change will add an implemention of
synchronization_internal::Waiter that can use
std:mutex/std::condition_variable to implement the per-thread
semaphore that absl::Mutex waits on. This implementation may at some
point become the default on platforms such as Windows where there
doesn't seem to be an easy way of supporting real absolute timeouts. In
this case we can defer to their standard library to implement correct
support.
PiperOrigin-RevId: 510204786
Change-Id: Icf4d695013fd060abbd53dae23e71ea36f731565
|
|
|
|
|
|
|
| |
instead of absl::ToUnixNanos(absl::Now());
PiperOrigin-RevId: 509829866
Change-Id: Ib34362762304ad6eb7980a1227d717069b84f656
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
APIs that take KernelTimeout as a parameter can now query if an
absolute or relative timeout was requested. If the underlying API can
only use one type of timeout, the code will do a reasonable
conversion.
The goal is to eventually enable the possibility of using wait times
that are based on monotonic clocks that are safe against system clock
steps.
PiperOrigin-RevId: 508541507
Change-Id: Id08bf13515f3e1bfd78d88393cde98a6fd3ef72c
|
|
|
|
|
| |
PiperOrigin-RevId: 508124592
Change-Id: Ib183e6e241c81b2760e7f849f8af8e7e2c30ea42
|
|
|
|
|
| |
PiperOrigin-RevId: 506323250
Change-Id: I0f7d4532c19088b011740ceff87ecec55cc34edb
|
|
|
|
|
| |
PiperOrigin-RevId: 503110285
Change-Id: I59c48b1486386e2db8fb62cf8bfa1a691865f704
|
|
|
|
|
| |
PiperOrigin-RevId: 497998566
Change-Id: I8d43311e280a5ea46c42abed55be62cd70d4d54a
|
|
|
|
|
| |
PiperOrigin-RevId: 497197704
Change-Id: I3865a874e04f6f55a1ab374b03451535a86bc5a3
|
|
|
|
|
| |
PiperOrigin-RevId: 496974198
Change-Id: I73b4013a2ad9fd37650d788cbd1e758b327b59d2
|
|
|
|
|
|
|
|
|
| |
Rather than add new friends every time
a new (internal) use arises, just expose
the timestamp.
PiperOrigin-RevId: 495722262
Change-Id: I25d2ce64769dc58cbe634259f07c600ce6c1e714
|
|
|
|
|
|
|
|
|
|
|
| |
correctly state that only the first registered hook will be honored.
The comments that imply otherwise were never true, and were a leftover artifact during initial development of the feature.
Also remove a TODO() I gave myself years ago; this is never going to happen and isn't worth the bother.
PiperOrigin-RevId: 495687371
Change-Id: I63f8ef57d659075bf290caae0617ea61ceb2c1db
|
|
|
|
|
| |
PiperOrigin-RevId: 491915718
Change-Id: I7469601857b5a3506163518d29f49792f3053b34
|
|
|
|
|
|
|
|
|
| |
TSan misses synchronization around passing PerThreadSynch between threads
since it happens inside of the Mutex code (which me mostly ignore),
so we need to ignore all accesses to the object.
PiperOrigin-RevId: 491297912
Change-Id: I13ea2015dee5c1a3fc4315c85112902ccffccc45
|
|
|
|
|
| |
PiperOrigin-RevId: 488986942
Change-Id: I2babb7ea30d60c544f55ca9ed02d9aed23051a12
|
|
|
|
|
| |
PiperOrigin-RevId: 488676817
Change-Id: I13f15bb93ab6dda4c56caf969be3c14f84ada6a0
|
|
|
|
|
|
|
|
|
|
|
| |
In order for Condition to work on Microsoft platforms, it has to store pointers to methods that are larger than we usually expect. MSVC pointers to methods from class hierarchies that employ multiple inheritance or virtual inheritance are strictly larger than pointers to methods in class hierarchies that only employ single inheritance.
This change introduces an opaque declaration of a class, which is not fulfilled. This declaration is used to calculate the size of the Condition method pointer allocation. Because the declaration is of unspecified inheritance, the compiler is forced to use a conservatively large allocation, which will thereby accommodate all method pointer sizes.
Because the `method_` and `function_` callbacks are only populated in mutually exclusive conditions, they can be allowed to take up the same space in the Condition object. This change combines the `method_` and `function_` fields and renames the new field to `callback_`. The constructor logic is updated to reflect the new field.
PiperOrigin-RevId: 486701312
Change-Id: If06832cc26f27d91e295183e44dc29440af5f9db
|
|\
| |
| |
| |
| | |
PiperOrigin-RevId: 485885633
Change-Id: Idfaf6ce22a9421fe05ae38029c8a68b720ce50ba
|
|/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
On single-core systems, a thread could be preempted while holding an
absl::Mutex, or even worse, the spin lock. If a FIFO thread wakes up and
tries to acquire this lock, it might not be able to yield() to the sleeping
thread.
Within MutexDelay(), a yield() and a sleep(10us) are used to yield the CPU.
The yield() would do nothing if the calling thread holds the highest
priority in the system. The 10us sleep() may not be able to reach the
scheduler either, if the system is slow enough.
This code path is known to be reachable in the following scenarios:
- a FIFO thread calls LockSlowLoop() with spin lock held by a normal thread
- a FIFO thread calls LockWhen*() with the Mutex held by a normal thread for a long time
- a FIFO thread calls Await*(), releases the Mutex to be held by a normal thread for a long time
This CL adds a mutex global for the sleep time, and sets it using the
return time of the a yield() call. Yield() must reach the
scheduler even when it fails to yield to anyone, and would allow sleep() to do the
same. A small constant multiplier (5) is also applied to overcome uncontrollable
factors in the runtime and help sleep() to consistently yield to another thread.
Upper and lower bounds for the sleep time is also controlled to block any unreasonable values.
PiperOrigin-RevId: 483459711
Change-Id: I14efadbadaf9244a2462f377b515147bda651c89
|
|
|
|
|
| |
PiperOrigin-RevId: 481192073
Change-Id: I1e3296f6be4ddf73bd5c7164f4673e97a0c2c408
|
|
|
|
|
| |
PiperOrigin-RevId: 479667897
Change-Id: I6085df8bfcfb009806230f8d71b576a1371a4d1f
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Addresses failures with the following, in some files:
-Wshorten-64-to-32
-Wimplicit-int-conversion
-Wsign-compare
-Wsign-conversion
-Wtautological-unsigned-zero-compare
(This specific CL focuses on .cc files in */internal/.)
Bug: chromium:1292951
PiperOrigin-RevId: 473868797
Change-Id: Ibe0b76e33f9e001d59862beaac54fb47bacd39b2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Addresses failures with the following, in some files:
-Wshorten-64-to-32
-Wimplicit-int-conversion
-Wsign-compare
-Wsign-conversion
-Wtautological-unsigned-zero-compare
(This specific CL focuses on miscellaneous non-test source files.)
Bug: chromium:1292951
PiperOrigin-RevId: 473054605
Change-Id: Ifd7b24966613ca915511a3a607095508068200b8
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Addresses failures with the following, in some files:
-Wshorten-64-to-32
-Wimplicit-int-conversion
-Wsign-compare
-Wsign-conversion
-Wtautological-unsigned-zero-compare
(This specific CL focuses on .cc files in */internal/.)
Bug: chromium:1292951
PiperOrigin-RevId: 471561809
Change-Id: I7abd6d83706f5ca135f1ce3458192a498a6280b9
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Addresses failures with the following, in some files:
-Wshorten-64-to-32
-Wimplicit-int-conversion
-Wsign-compare
-Wsign-conversion
-Wtautological-unsigned-zero-compare
(This specific CL focuses on .cc files in */internal/.)
Bug: chromium:1292951
PiperOrigin-RevId: 471549854
Change-Id: Id685d0e4666212926f4e001b8ef4930b6a33a4cc
|
|
|
|
|
| |
PiperOrigin-RevId: 471545981
Change-Id: I4d2c8b6d4f1e58976915bda78a77178b8bf80da8
|
|
|
|
|
| |
PiperOrigin-RevId: 471256712
Change-Id: I2a1e4846a524bccd3c935a40abab0c0218afdfc0
|
|
|
|
|
| |
PiperOrigin-RevId: 471030218
Change-Id: I727c7f8966fe9c96736283c8e1a13a76b3cdb53d
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Addresses failures with the following, in some files:
-Wshorten-64-to-32
-Wimplicit-int-conversion
-Wsign-compare
-Wsign-conversion
-Wtautological-unsigned-zero-compare
(This specific CL focuses on .cc files in dirs n-t, except string.)
Bug: chromium:1292951
PiperOrigin-RevId: 465287204
Change-Id: I0fe98ff78bf3c08d86992019eb626755f8b6803e
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Addresses failures with the following, in some files:
-Wshorten-64-to-32
-Wimplicit-int-conversion
-Wsign-compare
-Wsign-conversion
-Wtautological-unsigned-zero-compare
(This specific CL focuses on .h and win32 .inc files.)
Bug: chromium:1292951
PiperOrigin-RevId: 463835431
Change-Id: If8e5f7f651d5cd96035e23e4623bdb08a7fedabe
|
|\
| |
| |
| |
| | |
PiperOrigin-RevId: 463581990
Change-Id: I47359d4d2d2fcd2365b5ff9a5c3b61b5751e4ed2
|
| |
| |
| |
| | |
Signed-off-by: Elijah Conners <business@elijahpepe.com>
|
|/
|
|
|
|
|
|
|
|
|
| |
In the PostSynchEvent() function, the pos integer uses an implementation
of snprintf that is fundamentally unsafe: since the return value of
snprintf is the number of characters that would have been written to the
buffer, if an operation reaches the end of the buffer with more than one
character discarded, the return value will be greater than the buffer
size, requiring a check of the buffer's current size.
Signed-off-by: Elijah Conners <business@elijahpepe.com>
|
|
|
|
|
| |
PiperOrigin-RevId: 452542838
Change-Id: I45d80b220c0450d27423bb23504e95c25811877b
|
|
|
|
|
|
|
| |
calling thread doesn't hold the mutex.
PiperOrigin-RevId: 451410449
Change-Id: Iffd4c7463f1051474debbed256703589d96a548c
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Both Mutex and CondVar signal PerThreadSem/Waiter after satisfying the wait condition,
as the result the waiting thread may return w/o waiting on the
PerThreadSem/Waiter at all. If the waiting thread then exits, it currently
destroys Waiter object. As the result Waiter::Post can be called on
already destroyed object.
PerThreadSem/Waiter must be type-stable after creation and must not be destroyed.
The futex-based implementation is the only one that is not affected by the bug
since there is effectively nothing to destroy (maybe only UBSan/ASan
could complain about calling methods on a destroyed object).
Here is the problematic sequence of events:
1: void Mutex::Block(PerThreadSynch *s) {
2: while (s->state.load(std::memory_order_acquire) == PerThreadSynch::kQueued) {
3: if (!DecrementSynchSem(this, s, s->waitp->timeout)) {
4: PerThreadSynch *Mutex::Wakeup(PerThreadSynch *w) {
5: ...
6: w->state.store(PerThreadSynch::kAvailable, std::memory_order_release);
7: IncrementSynchSem(this, w);
8: ...
9: }
Consider line 6 is executed, then line 2 observes kAvailable and
line 3 is not called. The thread executing Mutex::Block returns from
the method, acquires the mutex, releases the mutex, exits and destroys
PerThreadSem/Waiter.
Now Mutex::Wakeup resumes and executes line 7 on the destroyed object. Boom!
CondVar uses a similar pattern.
Moreover the semaphore-based Waiter implementation is not even destruction-safe
(the Waiter cannot be used to signal own destruction). So even if Mutex/CondVar
would always pair Waiter::Post with Waiter::Wait before destroying PerThreadSem/Waiter,
it would still be subject to use-after-free bug on the semaphore.
PiperOrigin-RevId: 449159939
Change-Id: I497134fa8b6ce1294a422827c5f0de0e897cea31
|
|
|
|
|
|
|
|
| |
CondVar::WaitWithTimeout can live-lock when timeout is racing with Signal/SignalAll
and Signal/SignalAll thread is not scheduled due to priorities, affinity or other
scheduler artifacts. This could lead to stalls of up to tens of seconds in some cases.
PiperOrigin-RevId: 449159670
Change-Id: I64bbd277c1f91964cfba3306ba8a80eeadf85f64
|
|
|
|
|
| |
PiperOrigin-RevId: 449067700
Change-Id: I972b1736c28d76ed500e9ad6fd15c7a469a5825f
|
|
|
|
|
| |
PiperOrigin-RevId: 448159349
Change-Id: I6b25a90d8a3b6d3a888274d156aa696d77fb042d
|
|
|
|
|
| |
PiperOrigin-RevId: 443723710
Change-Id: Ic39b0cf2b289efa9cd9434616949dd08a1a35117
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
--
f4c7e510922668c68be4aa79a00867c3d3ca9f95 by Derek Mauro <dmauro@google.com>:
Many improvements to LeakChecker builds
The presence of the LeakChecker is now detected when possible. GCC
users using LeakChecker in standalone mode still need to use
-DLEAK_CHECKER. This is now documented in the header.
The hacky targets used for testing leak checking have been removed in
favor of testing in AddressSanitizer mode on Kokoro.
Fixes #885
Fixes #1153
PiperOrigin-RevId: 441203393
Change-Id: Ibe64ef6b104bcaf31839ff7184e558cc86abdd1c
--
5c70a23aa83b8152ab95d2cf21662fc63c80ef7d by Abseil Team <absl-team@google.com>:
Add a benchmark for stacktrace
PiperOrigin-RevId: 441196473
Change-Id: I4c9aa2e797aa2cae09abfaaee3abe5c09eb62fc4
--
50b406052273b9d5bad04a7860a96e4d5d956c02 by Abseil Team <absl-team@google.com>:
Internal change.
PiperOrigin-RevId: 441114481
Change-Id: I667af7a50d5631ca91289dd24c91ba90233e0184
--
568b4eaac120b420bce5290179d407d2b57d5bae by Dino Radakovic <dinor@google.com>:
Internal change
PiperOrigin-RevId: 440894155
Change-Id: Ia587ffc65a8321126585fb363b7c0ca8cc2a0da2
--
d53948eace4f3a10ac5a6c1496dc51b81adc412c by Abseil Team <absl-team@google.com>:
Explicitly give internal linkage to symbols which are not used outside of their
translation units.
PiperOrigin-RevId: 440424519
Change-Id: I531c5e229d443375483b7550a34f48042589a99b
GitOrigin-RevId: f4c7e510922668c68be4aa79a00867c3d3ca9f95
|