diff options
author | 2019-04-09 18:10:26 +0100 | |
---|---|---|
committer | 2019-04-10 09:28:44 +0000 | |
commit | 1ed4515facecea8dd5801eca752768043e4de01d (patch) | |
tree | 3e16243e33dddbe1dd9ee7e918d8113b3855f4c1 | |
parent | 51d5a30592d1e6f6129cf8628178b201d345ce36 (diff) |
Fix flaky 137-cfi test.
Avoid modifying the native debug info while we are unwinding.
Bug: 111411286
Test: test.py --host -b -r -t 137-cfi
Change-Id: Ie5a173d0fb545011413fa0326135aa9c56006e8d
-rw-r--r-- | runtime/jit/debugger_interface.cc | 4 | ||||
-rw-r--r-- | runtime/jit/debugger_interface.h | 6 | ||||
-rw-r--r-- | test/137-cfi/cfi.cc | 5 |
3 files changed, 15 insertions, 0 deletions
diff --git a/runtime/jit/debugger_interface.cc b/runtime/jit/debugger_interface.cc index 0ada45884b..f522be81bd 100644 --- a/runtime/jit/debugger_interface.cc +++ b/runtime/jit/debugger_interface.cc @@ -423,4 +423,8 @@ size_t GetJitMiniDebugInfoMemUsage() { return size; } +Mutex* GetNativeDebugInfoLock() { + return &g_jit_debug_lock; +} + } // namespace art diff --git a/runtime/jit/debugger_interface.h b/runtime/jit/debugger_interface.h index 5bb4682d6c..19507b0f9a 100644 --- a/runtime/jit/debugger_interface.h +++ b/runtime/jit/debugger_interface.h @@ -27,6 +27,7 @@ namespace art { class DexFile; +class Mutex; class Thread; // This method is declared in the compiler library. @@ -60,6 +61,11 @@ void RemoveNativeDebugInfoForJit(Thread* self, const void* code_ptr); // Returns approximate memory used by debug info for JIT code. size_t GetJitMiniDebugInfoMemUsage(); +// Get the lock which protects the native debug info. +// Used only in tests to unwind while the JIT thread is running. +// TODO: Unwinding should be race-free. Remove this. +Mutex* GetNativeDebugInfoLock(); + } // namespace art #endif // ART_RUNTIME_JIT_DEBUGGER_INTERFACE_H_ diff --git a/test/137-cfi/cfi.cc b/test/137-cfi/cfi.cc index 4d886f5a4d..6b1480f639 100644 --- a/test/137-cfi/cfi.cc +++ b/test/137-cfi/cfi.cc @@ -32,9 +32,11 @@ #include "base/file_utils.h" #include "base/logging.h" #include "base/macros.h" +#include "base/mutex.h" #include "base/utils.h" #include "gc/heap.h" #include "gc/space/image_space.h" +#include "jit/debugger_interface.h" #include "oat_file.h" #include "runtime.h" @@ -84,6 +86,7 @@ extern "C" JNIEXPORT jint JNICALL Java_Main_startSecondaryProcess(JNIEnv*, jclas extern "C" JNIEXPORT jboolean JNICALL Java_Main_sigstop(JNIEnv*, jclass) { #if __linux__ + MutexLock mu(Thread::Current(), *GetNativeDebugInfoLock()); // Avoid races with the JIT thread. raise(SIGSTOP); #endif return true; // Prevent the compiler from tail-call optimizing this method away. @@ -133,6 +136,8 @@ static void MoreErrorInfo(pid_t pid, bool sig_quit_on_fail) { extern "C" JNIEXPORT jboolean JNICALL Java_Main_unwindInProcess(JNIEnv*, jclass) { #if __linux__ + MutexLock mu(Thread::Current(), *GetNativeDebugInfoLock()); // Avoid races with the JIT thread. + std::unique_ptr<Backtrace> bt(Backtrace::Create(BACKTRACE_CURRENT_PROCESS, GetTid())); if (!bt->Unwind(0, nullptr)) { printf("Cannot unwind in process.\n"); |