From 4e3387cb5f2a0700659bbc84a8b9d70774f11889 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 18 Sep 2019 16:56:57 -0700 Subject: [PATCH] Lengthen ScopedDisableMallocTimeout timeout to 10 seconds memunreachable_unit_test is flaking sometimes with timeouts in ScopedDisableMallocTimeout. They can't be real deadlocks, which is what this timeout is designed to detect, the Enable() called from the signal handler wasn't doing anything because disabled_ hadn't been set yet. Lengthen the timeout to 10 seconds, and set disabled_ before starting to take the malloc locks in malloc_disable. If this really deadlocked then calling malloc_enable inside malloc_disable would make a mess of the locks, but it would at least unlock whatever lock was deadlocked and give the test a chance to report the error. Bug: 141229513 Test: atest memunreachable_unit_test Change-Id: I3578964577025aaa4bbba09027afd22997d4adbd --- libmemunreachable/ScopedDisableMalloc.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libmemunreachable/ScopedDisableMalloc.h b/libmemunreachable/ScopedDisableMalloc.h index 655e82687..dc863c982 100644 --- a/libmemunreachable/ScopedDisableMalloc.h +++ b/libmemunreachable/ScopedDisableMalloc.h @@ -34,8 +34,8 @@ class DisableMallocGuard { void Disable() { if (!disabled_) { - malloc_disable(); disabled_ = true; + malloc_disable(); } } @@ -71,8 +71,7 @@ class ScopedDisableMalloc { class ScopedDisableMallocTimeout { public: - explicit ScopedDisableMallocTimeout( - std::chrono::milliseconds timeout = std::chrono::milliseconds(2000)) + explicit ScopedDisableMallocTimeout(std::chrono::milliseconds timeout = std::chrono::seconds(10)) : timeout_(timeout), timed_out_(false), disable_malloc_() { Disable(); }