From 4b2d1c56cfd540e477a297abb70a18b72ef1ebfc Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Wed, 6 Mar 2019 11:21:11 +0000 Subject: Fix memory leak in CommonCompilerTest::CompileMethod(). And enforce that we successfully compile the method. This fixes ASAN tests broken by https://android-review.googlesource.com/919053 Test: run_build_test_target.py art-gtest-heap-poisoning Change-Id: I98b6c11e097bd9aea6605f3b77b1bcbb2206dbd0 --- compiler/common_compiler_test.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'compiler/common_compiler_test.cc') diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc index d59cb17909..a44b9ae523 100644 --- a/compiler/common_compiler_test.cc +++ b/compiler/common_compiler_test.cc @@ -173,7 +173,7 @@ void CommonCompilerTest::CompileMethod(ArtMethod* method) { TimingLogger timings("CommonCompilerTest::CompileMethod", false, false); TimingLogger::ScopedTiming t(__FUNCTION__, &timings); CompiledMethodStorage storage(/*swap_fd=*/ -1); - const CompiledMethod* compiled_method = nullptr; + CompiledMethod* compiled_method = nullptr; { DCHECK(!Runtime::Current()->IsStarted()); Thread* self = Thread::Current(); @@ -204,8 +204,12 @@ void CommonCompilerTest::CompileMethod(ArtMethod* method) { } compiler_options_->verification_results_ = nullptr; } - TimingLogger::ScopedTiming t2("MakeExecutable", &timings); - MakeExecutable(method, compiled_method); + CHECK(method != nullptr); + { + TimingLogger::ScopedTiming t2("MakeExecutable", &timings); + MakeExecutable(method, compiled_method); + } + CompiledMethod::ReleaseSwapAllocatedCompiledMethod(&storage, compiled_method); } void CommonCompilerTest::CompileDirectMethod(Handle class_loader, -- cgit v1.2.3-59-g8ed1b