diff options
author | Mathieu Chartier <mathieuc@google.com> | 2015-02-23 15:31:58 -0800 |
---|---|---|
committer | Mathieu Chartier <mathieuc@google.com> | 2015-02-23 16:22:32 -0800 |
commit | 05d1461f40a065acb66e6d5248609cf33c5b900a (patch) | |
tree | c31a40484dabb28d758f2dbcd375b6f96f6a8dd9 /runtime/runtime.cc | |
parent | 735969139b162f9d45a3c0e47dc24a8aec63c736 (diff) | |
download | art-05d1461f40a065acb66e6d5248609cf33c5b900a.zip art-05d1461f40a065acb66e6d5248609cf33c5b900a.tar.gz art-05d1461f40a065acb66e6d5248609cf33c5b900a.tar.bz2 |
Only detach shutdown thread if we attached it
Speculative fix to:
"Request to unregister unattached thread" bug.
Bug: 18713034
Change-Id: I6e69088dd66970c704010397a11e3758cf107ff9
Diffstat (limited to 'runtime/runtime.cc')
-rw-r--r-- | runtime/runtime.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/runtime/runtime.cc b/runtime/runtime.cc index f38f65e..9a2e901 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -190,7 +190,8 @@ Runtime::~Runtime() { } Thread* self = Thread::Current(); - if (self == nullptr) { + const bool attach_shutdown_thread = self == nullptr; + if (attach_shutdown_thread) { CHECK(AttachCurrentThread("Shutdown thread", false, nullptr, false)); self = Thread::Current(); } else { @@ -212,8 +213,10 @@ Runtime::~Runtime() { self->GetJniEnv()->CallStaticVoidMethod(WellKnownClasses::java_lang_Daemons, WellKnownClasses::java_lang_Daemons_stop); } - DetachCurrentThread(); - self = nullptr; + if (attach_shutdown_thread) { + DetachCurrentThread(); + self = nullptr; + } // Shut down background profiler before the runtime exits. if (profiler_started_) { |