Commit 1d474dcf authored by Kunihiko Sakamoto's avatar Kunihiko Sakamoto Committed by Commit Bot

Revert "Fix thread checks in HangWatcher"

This reverts commit 07c000ce.

Reason for revert: use-of-uninitialized-value is detected in Linux MSan Tests.
https://ci.chromium.org/p/chromium/builders/ci/Linux%20MSan%20Tests/25981

==29008==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x5580a100b292 in base::HangWatcher::GetTimeSinceLastCriticalMemoryPressureCrashKey() ./../../base/threading/hang_watcher.cc:268:7


Original change's description:
> Fix thread checks in HangWatcher
>
> Remove the thread check that would never pass and make the variable
> that is used by multiple threads thread safe.
>
> Bug: 1142155
> Change-Id: Iae33e15733eb78a47a664515e1abec671edbb64d
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2495579
> Reviewed-by: François Doray <fdoray@chromium.org>
> Commit-Queue: Oliver Li <olivierli@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#820817}

TBR=fdoray@chromium.org,olivierli@chromium.org

Change-Id: I463c2928c91878d396a0dd7ebb93b3c625e26a56
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1142155
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2500385Reviewed-by: default avatarKunihiko Sakamoto <ksakamoto@chromium.org>
Commit-Queue: Kunihiko Sakamoto <ksakamoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821004}
parent aedef32f
...@@ -264,9 +264,7 @@ HangWatcher::GetTimeSinceLastCriticalMemoryPressureCrashKey() { ...@@ -264,9 +264,7 @@ HangWatcher::GetTimeSinceLastCriticalMemoryPressureCrashKey() {
static debug::CrashKeyString* crash_key = AllocateCrashKeyString( static debug::CrashKeyString* crash_key = AllocateCrashKeyString(
"seconds-since-last-memory-pressure", kCrashKeyContentSize); "seconds-since-last-memory-pressure", kCrashKeyContentSize);
const base::TimeTicks last_critical_memory_pressure_time = if (last_critical_memory_pressure_.is_null()) {
last_critical_memory_pressure_.load(std::memory_order_relaxed);
if (last_critical_memory_pressure_time.is_null()) {
constexpr char kNoMemoryPressureMsg[] = "No critical memory pressure"; constexpr char kNoMemoryPressureMsg[] = "No critical memory pressure";
static_assert( static_assert(
base::size(kNoMemoryPressureMsg) <= base::size(kNoMemoryPressureMsg) <=
...@@ -275,7 +273,7 @@ HangWatcher::GetTimeSinceLastCriticalMemoryPressureCrashKey() { ...@@ -275,7 +273,7 @@ HangWatcher::GetTimeSinceLastCriticalMemoryPressureCrashKey() {
return debug::ScopedCrashKeyString(crash_key, kNoMemoryPressureMsg); return debug::ScopedCrashKeyString(crash_key, kNoMemoryPressureMsg);
} else { } else {
base::TimeDelta time_since_last_critical_memory_pressure = base::TimeDelta time_since_last_critical_memory_pressure =
base::TimeTicks::Now() - last_critical_memory_pressure_time; base::TimeTicks::Now() - last_critical_memory_pressure_;
return debug::ScopedCrashKeyString( return debug::ScopedCrashKeyString(
crash_key, base::NumberToString( crash_key, base::NumberToString(
time_since_last_critical_memory_pressure.InSeconds())); time_since_last_critical_memory_pressure.InSeconds()));
...@@ -285,10 +283,11 @@ HangWatcher::GetTimeSinceLastCriticalMemoryPressureCrashKey() { ...@@ -285,10 +283,11 @@ HangWatcher::GetTimeSinceLastCriticalMemoryPressureCrashKey() {
void HangWatcher::OnMemoryPressure( void HangWatcher::OnMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) { base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) {
DCHECK_CALLED_ON_VALID_THREAD(hang_watcher_thread_checker_);
if (memory_pressure_level == if (memory_pressure_level ==
base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) { base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) {
last_critical_memory_pressure_.store(base::TimeTicks::Now(), last_critical_memory_pressure_ = base::TimeTicks::Now();
std::memory_order_relaxed);
} }
} }
......
...@@ -334,9 +334,8 @@ class BASE_EXPORT HangWatcher : public DelegateSimpleThread::Delegate { ...@@ -334,9 +334,8 @@ class BASE_EXPORT HangWatcher : public DelegateSimpleThread::Delegate {
base::MemoryPressureListener memory_pressure_listener_; base::MemoryPressureListener memory_pressure_listener_;
// The last time at which a critical memory pressure signal was received, or // The last time at which a critical memory pressure signal was received, or
// null if no signal was ever received. Atomic because it's set and read from // null if no signal was ever received.
// different threads. base::TimeTicks last_critical_memory_pressure_;
std::atomic<base::TimeTicks> last_critical_memory_pressure_;
// The time after which all deadlines in |watch_states_| need to be for a hang // The time after which all deadlines in |watch_states_| need to be for a hang
// to be reported. // to be reported.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment