[clang] [clang-repl] Set up executor implicitly to account for init PTUs (PR #84758)
Vassil Vassilev via cfe-commits
cfe-commits at lists.llvm.org
Sat Apr 13 23:21:00 PDT 2024
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/84758 at github.com>
================
@@ -14,7 +14,7 @@ struct A { int a; A(int a) : a(a) {} virtual ~A(); };
// PartialTranslationUnit.
inline A::~A() { printf("~A(%d)\n", a); }
-// Create one instance with new and delete it.
+// Create one instance with new and delete it. We crash here now:
A *a1 = new A(1);
----------------
vgvassilev wrote:
Here is a report from valgrind and we seem to have a problem:
```
==858864== Warning: set address range perms: large range [0x108000, 0x11f2c000) (defined)
==858864== Invalid read of size 8
==858864== at 0x11E99BE: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::length() const (basic_string.h:927)
==858864== by 0x11F1E3B: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (basic_string.tcc:259)
==858864== by 0x11EE135: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (basic_string.h:1387)
==858864== by 0x11EB15C: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (basic_string.h:681)
==858864== by 0x16F1819: llvm::DataLayout::operator=(llvm::DataLayout const&) (DataLayout.h:206)
==858864== by 0x1A552E9: llvm::DataLayout::init(llvm::Module const*) (DataLayout.cpp:557)
==858864== by 0x1A552B3: llvm::DataLayout::DataLayout(llvm::Module const*) (DataLayout.cpp:554)
==858864== by 0x33797CA: clang::CodeGen::CodeGenTBAA::getVTablePtrAccessInfo(llvm::Type*) (CodeGenTBAA.cpp:274)
==858864== by 0x3221BC3: clang::CodeGen::CodeGenModule::getTBAAVTablePtrAccessInfo(llvm::Type*) (CodeGenModule.cpp:1424)
==858864== by 0x2DCA94E: clang::CodeGen::CodeGenFunction::InitializeVTablePointer(clang::CodeGen::CodeGenFunction::VPtr const&) (CGClass.cpp:2592)
==858864== by 0x2DCAFC8: clang::CodeGen::CodeGenFunction::InitializeVTablePointers(clang::CXXRecordDecl const*) (CGClass.cpp:2676)
==858864== by 0x2DC519C: clang::CodeGen::CodeGenFunction::EmitDestructorBody(clang::CodeGen::FunctionArgList&) (CGClass.cpp:1525)
==858864== Address 0x13599270 is 512 bytes inside a block of size 800 free'd
==858864== at 0x12D50B6F: operator delete(void*, unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==858864== by 0x1E5A922: std::default_delete<llvm::Module>::operator()(llvm::Module*) const (unique_ptr.h:85)
==858864== by 0x1E5A867: std::__uniq_ptr_impl<llvm::Module, std::default_delete<llvm::Module> >::reset(llvm::Module*) (unique_ptr.h:182)
==858864== by 0x1E5A800: std::unique_ptr<llvm::Module, std::default_delete<llvm::Module> >::reset(llvm::Module*) (unique_ptr.h:456)
==858864== by 0x1E4F8B8: std::unique_ptr<llvm::Module, std::default_delete<llvm::Module> >::operator=(decltype(nullptr)) (unique_ptr.h:397)
==858864== by 0x1E4B5DC: llvm::orc::ThreadSafeModule::~ThreadSafeModule() (ThreadSafeModule.h:116)
==858864== by 0x1F4DF4F: llvm::orc::IRMaterializationUnit::~IRMaterializationUnit() (Layer.h:31)
==858864== by 0x1FCE1D5: llvm::orc::BasicIRLayerMaterializationUnit::~BasicIRLayerMaterializationUnit() (Layer.h:120)
==858864== by 0x1FCE1F5: llvm::orc::BasicIRLayerMaterializationUnit::~BasicIRLayerMaterializationUnit() (Layer.h:120)
==858864== by 0x1FCE235: std::default_delete<llvm::orc::BasicIRLayerMaterializationUnit>::operator()(llvm::orc::BasicIRLayerMaterializationUnit*) const (unique_ptr.h:85)
==858864== by 0x1FCCFFD: std::unique_ptr<llvm::orc::BasicIRLayerMaterializationUnit, std::default_delete<llvm::orc::BasicIRLayerMaterializationUnit> >::~unique_ptr() (unique_ptr.h:361)
==858864== by 0x1FCA870: llvm::orc::IRLayer::add(llvm::IntrusiveRefCntPtr<llvm::orc::ResourceTracker>, llvm::orc::ThreadSafeModule) (Layer.cpp:27)
==858864== Block was alloc'd at
==858864== at 0x12D4E013: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==858864== by 0x2CC7B86: (anonymous namespace)::CodeGeneratorImpl::CodeGeneratorImpl(clang::DiagnosticsEngine&, llvm::StringRef, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, clang::HeaderSearchOptions const&, clang::PreprocessorOptions const&, clang::CodeGenOptions const&, llvm::LLVMContext&, clang::CoverageSourceInfo*) (ModuleBuilder.cpp:87)
==858864== by 0x2CC90C0: clang::CreateLLVMCodeGen(clang::DiagnosticsEngine&, llvm::StringRef, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, clang::HeaderSearchOptions const&, clang::PreprocessorOptions const&, clang::CodeGenOptions const&, llvm::LLVMContext&, clang::CoverageSourceInfo*) (ModuleBuilder.cpp:372)
==858864== by 0x2C8749E: clang::BackendConsumer::BackendConsumer(clang::BackendAction, clang::DiagnosticsEngine&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, clang::HeaderSearchOptions const&, clang::PreprocessorOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, clang::FileManager const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, llvm::SmallVector<clang::CodeGenAction::LinkModule, 4u>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >, llvm::LLVMContext&, clang::CoverageSourceInfo*) (CodeGenAction.cpp:127)
==858864== by 0x2C8C2A0: clang::CodeGenAction::CreateASTConsumer(clang::CompilerInstance&, llvm::StringRef) (CodeGenAction.cpp:1051)
==858864== by 0x22A1E64: clang::WrapperFrontendAction::CreateASTConsumer(clang::CompilerInstance&, llvm::StringRef) (FrontendAction.cpp:1207)
==858864== by 0x229B7A5: clang::FrontendAction::CreateWrappedASTConsumer(clang::CompilerInstance&, llvm::StringRef) (FrontendAction.cpp:166)
==858864== by 0x22A08F0: clang::FrontendAction::BeginSourceFile(clang::CompilerInstance&, clang::FrontendInputFile const&) (FrontendAction.cpp:955)
==858864== by 0x2198EA6: clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (CompilerInstance.cpp:1061)
==858864== by 0x2573ECA: clang::IncrementalParser::IncrementalParser(clang::Interpreter&, std::unique_ptr<clang::CompilerInstance, std::default_delete<clang::CompilerInstance> >, llvm::LLVMContext&, llvm::Error&) (IncrementalParser.cpp:211)
==858864== by 0x2562095: std::_MakeUniq<clang::IncrementalParser>::__single_object std::make_unique<clang::IncrementalParser, clang::Interpreter&, std::unique_ptr<clang::CompilerInstance, std::default_delete<clang::CompilerInstance> >, llvm::LLVMContext&, llvm::Error&>(clang::Interpreter&, std::unique_ptr<clang::CompilerInstance, std::default_delete<clang::CompilerInstance> >&&, llvm::LLVMContext&, llvm::Error&) (unique_ptr.h:962)
==858864== by 0x25599FD: clang::Interpreter::Interpreter(std::unique_ptr<clang::CompilerInstance, std::default_delete<clang::CompilerInstance> >, llvm::Error&) (Interpreter.cpp:236)
==858864==
```
https://github.com/llvm/llvm-project/pull/84758
More information about the cfe-commits
mailing list