From 63deaad18853e55097761e47a9eedd12eb0c1e58 Mon Sep 17 00:00:00 2001 From: Shih-wei Liao Date: Tue, 6 Mar 2012 17:26:37 -0800 Subject: Fix memory corruption due to premature llvm_shutdown(). Under LLVM, multiple compiler-related gtests randomly crashes from time to time, because common_test.h has code to new multiple compiler instances. Multiple CompilerLLVM instances may cause crash if one shuts down LLVM prematurely. This fix uses static class member. Destructor is where we shut down LLVM. Change-Id: Ied371794af7ca9eb2c9fe6b278fd779a61a4a753 --- src/compiler_llvm/compiler_llvm.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/compiler_llvm/compiler_llvm.h') diff --git a/src/compiler_llvm/compiler_llvm.h b/src/compiler_llvm/compiler_llvm.h index 7481c8c2e2..6332fb3886 100644 --- a/src/compiler_llvm/compiler_llvm.h +++ b/src/compiler_llvm/compiler_llvm.h @@ -107,6 +107,13 @@ class CompilerLLVM { std::string bitcode_filename_; + class LLVMInitializer { + public: + LLVMInitializer(); + ~LLVMInitializer(); + }; + static LLVMInitializer llvm_initialize_guard; + DISALLOW_COPY_AND_ASSIGN(CompilerLLVM); }; -- cgit v1.2.3-59-g8ed1b