diff options
author | Andreas Gampe <agampe@google.com> | 2014-09-09 19:53:48 -0700 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2014-09-10 15:50:42 -0700 |
commit | 928f72bd75c385ba2708c58521171a77264d4486 (patch) | |
tree | 86f7fa7a21e3f6d21c9cab2d4fffe4aaa42dc458 /runtime/fault_handler.cc | |
parent | dab9ed52f2df7189b81ccf3237b030ff638a492a (diff) | |
download | art-928f72bd75c385ba2708c58521171a77264d4486.zip art-928f72bd75c385ba2708c58521171a77264d4486.tar.gz art-928f72bd75c385ba2708c58521171a77264d4486.tar.bz2 |
ART: Fix things for valgrind
Wire up valgrind gtests. Add valgrind-test-art-host, currently
only depending on valgrind-test-art-host-gtest32.
Fix an Alloc setting to allow running valgrind.
Refactor the fault handler to manage (and correctly release) the
handlers.
Fix minor failure-case leaks exposed by tests.
Failing tests:
The optimizing compiler is leaking non-arena-ed structures
(e.g., assembler buffers), as code generators are not destroyed.
The solution has been moved to a follow-up CL.
Note: All 64b tests are failing as we cannot allocate a heap.
Change-Id: I7f854cfd098d9f68107ce492363e7dba9a82b9fa
Diffstat (limited to 'runtime/fault_handler.cc')
-rw-r--r-- | runtime/fault_handler.cc | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/runtime/fault_handler.cc b/runtime/fault_handler.cc index 47696f9..fede2f8 100644 --- a/runtime/fault_handler.cc +++ b/runtime/fault_handler.cc @@ -19,6 +19,7 @@ #include <setjmp.h> #include <sys/mman.h> #include <sys/ucontext.h> +#include "base/stl_util.h" #include "mirror/art_method.h" #include "mirror/class.h" #include "sigchain.h" @@ -115,13 +116,23 @@ void FaultManager::Init() { initialized_ = true; } -void FaultManager::Shutdown() { +void FaultManager::Release() { if (initialized_) { UnclaimSignalChain(SIGSEGV); initialized_ = false; } } +void FaultManager::Shutdown() { + if (initialized_) { + Release(); + + // Free all handlers. + STLDeleteElements(&generated_code_handlers_); + STLDeleteElements(&other_handlers_); + } +} + void FaultManager::HandleFault(int sig, siginfo_t* info, void* context) { // BE CAREFUL ALLOCATING HERE INCLUDING USING LOG(...) // @@ -156,9 +167,9 @@ void FaultManager::HandleFault(int sig, siginfo_t* info, void* context) { // Now set up the nested signal handler. - // Shutdown the fault manager so that it will remove the signal chain for + // Release the fault manager so that it will remove the signal chain for // SIGSEGV and we call the real sigaction. - fault_manager.Shutdown(); + fault_manager.Release(); // The action for SIGSEGV should be the default handler now. @@ -226,6 +237,7 @@ void FaultManager::HandleFault(int sig, siginfo_t* info, void* context) { } void FaultManager::AddHandler(FaultHandler* handler, bool generated_code) { + DCHECK(initialized_); if (generated_code) { generated_code_handlers_.push_back(handler); } else { |