summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mythri Alle <mythria@google.com> 2023-04-25 13:10:17 +0000
committer Mythri Alle <mythria@google.com> 2023-05-15 08:47:30 +0000
commit0bd8ed3d79b84acbfa826fd5735b51e513236208 (patch)
treeca1cf8ea07b9f2a91f91065abd7826c02b682302
parent3557b865be8f294cacff68e10fa2e6c2ba87a03b (diff)
Don't record thread information from shutdown thread
If we are shutting down with no attached thread we re-attach the thread. If re-attaching gets into some problems we unregister the thread again which records the information about the thread again. So just ignore updates from the Shutdown thread. Bug: 279548114 Test: art/test.py -t 2246 (cherry picked from https://android-review.googlesource.com/q/commit:d67de1bf6a8d229f485c7c530015cae257ec13f8) Merged-In: I5357c0653e5006428f75b5449889495dfa7f543d Change-Id: I5357c0653e5006428f75b5449889495dfa7f543d Cherrypick to fix a regression in method tracing in non-streaming mode.
-rw-r--r--runtime/trace.cc17
1 files changed, 15 insertions, 2 deletions
diff --git a/runtime/trace.cc b/runtime/trace.cc
index e23ff0525a..745c2524de 100644
--- a/runtime/trace.cc
+++ b/runtime/trace.cc
@@ -565,6 +565,14 @@ void Trace::Start(std::unique_ptr<File>&& trace_file_in,
}
}
+namespace {
+
+bool IsShutdownThread(std::string name) {
+ return (name.compare("Shutdown thread") == 0);
+}
+
+} // namespace
+
void Trace::StopTracing(bool finish_tracing, bool flush_file) {
Runtime* const runtime = Runtime::Current();
Thread* const self = Thread::Current();
@@ -629,7 +637,7 @@ void Trace::StopTracing(bool finish_tracing, bool flush_file) {
// detached we record the information about the threads_list_. We re-attach the current
// thread again as a "Shutdown thread" in the process of shutting down. So don't record
// information about shutdown threads.
- if (name.compare("Shutdown thread") != 0) {
+ if (!IsShutdownThread(name)) {
// This information is updated here when stopping tracing and also when a thread is
// detaching. In thread detach, we first update this information and then remove the
// thread from the list of active threads. If the tracing was stopped in between these
@@ -1277,7 +1285,12 @@ void Trace::StoreExitingThreadInfo(Thread* thread) {
if (the_trace_ != nullptr) {
std::string name;
thread->GetThreadName(name);
- the_trace_->threads_list_.Put(thread->GetTid(), name);
+ // In tests, we destroy VM after already detaching the current thread. When a thread is
+ // detached we record the information about the threads_list_. Re-attaching thread can fail
+ // sometimes which unregisters the thread again. So ignore upadtes from shutdown thread.
+ if (!IsShutdownThread(name)) {
+ the_trace_->threads_list_.Put(thread->GetTid(), name);
+ }
}
}