diff options
-rw-r--r-- | perfetto_hprof/perfetto_hprof.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/perfetto_hprof/perfetto_hprof.cc b/perfetto_hprof/perfetto_hprof.cc index ebba1e3e17..8bcf0bd125 100644 --- a/perfetto_hprof/perfetto_hprof.cc +++ b/perfetto_hprof/perfetto_hprof.cc @@ -32,6 +32,7 @@ #include <time.h> #include <limits> +#include <optional> #include <type_traits> #include "gc/heap-visit-objects-inl.h" @@ -584,10 +585,10 @@ void DumpPerfetto(art::Thread* self) { // We need to do this before the fork, because otherwise it can deadlock // waiting for the GC, as all other threads get terminated by the clone, but // their locks are not released. - art::gc::ScopedGCCriticalSection gcs(self, art::gc::kGcCauseHprof, - art::gc::kCollectorTypeHprof); + std::optional<art::gc::ScopedGCCriticalSection> gcs(std::in_place, self, art::gc::kGcCauseHprof, + art::gc::kCollectorTypeHprof); - art::ScopedSuspendAll ssa(__FUNCTION__, /* long_suspend=*/ true); + std::optional<art::ScopedSuspendAll> ssa(std::in_place, __FUNCTION__, /* long_suspend=*/ true); pid_t pid = fork(); if (pid == -1) { @@ -597,6 +598,10 @@ void DumpPerfetto(art::Thread* self) { } if (pid != 0) { // Parent + // Stop the thread suspension as soon as possible to allow the rest of the application to + // continue while we waitpid here. + ssa.reset(); + gcs.reset(); int stat_loc; for (;;) { if (waitpid(pid, &stat_loc, 0) != -1 || errno != EINTR) { |