[Lldb-commits] [PATCH] D136650: Make CompilerType safe [Was: Add a check for TypeSystem use-after-free problems]

Adrian Prantl via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 2 16:09:44 PDT 2022


aprantl updated this revision to Diff 472785.
aprantl added a comment.

I have an updated patch here that I started working on before I saw Pavel's comment.

This version removes a lot of the `std::weak_ptr<TypeSystem>*` uglyness by introducing a wrapper class `CompilerType::ManagedTypeSystem` that has a `dyn_cast_or_null()` method and hides the fact that we store weak pointers in CompilerType. Now the only sites that need to know about the weak pointer implementation detail are the ones that deal with creating TypeSystems.

Meanwhile I did some unscientific measurements of attaching LLDB to LLDB and running a few expressions and any difference that an extra pointer in CompilerType makes is smaller than the difference between subsequent runs.

Based on that I'm going to rework this now to just store a WP in CompilerType directly, while still returning a wrapper object with a convenient dyn_cast method. That should be the best of both worlds.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136650/new/

https://reviews.llvm.org/D136650

Files:
  lldb/include/lldb/Core/Module.h
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/SymbolFile.h
  lldb/include/lldb/Symbol/SymbolFileOnDemand.h
  lldb/include/lldb/Symbol/TaggedASTType.h
  lldb/include/lldb/Symbol/Type.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/include/lldb/Target/Target.h
  lldb/include/lldb/lldb-enumerations.h
  lldb/include/lldb/lldb-forward.h
  lldb/source/API/SBModule.cpp
  lldb/source/API/SBTarget.cpp
  lldb/source/API/SBType.cpp
  lldb/source/Breakpoint/Watchpoint.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Core/DumpDataExtractor.cpp
  lldb/source/Core/Module.cpp
  lldb/source/Core/ValueObjectMemory.cpp
  lldb/source/Core/ValueObjectRegister.cpp
  lldb/source/DataFormatters/VectorType.cpp
  lldb/source/Expression/Materializer.cpp
  lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp
  lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangUtil.cpp
  lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp
  lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
  lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
  lldb/source/Plugins/Language/ObjC/CoreMedia.cpp
  lldb/source/Plugins/Language/ObjC/NSArray.cpp
  lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
  lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
  lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
  lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
  lldb/source/Plugins/Platform/Linux/PlatformLinux.h
  lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
  lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
  lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
  lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
  lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
  lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/source/Symbol/SymbolFile.cpp
  lldb/source/Symbol/SymbolFileOnDemand.cpp
  lldb/source/Symbol/Type.cpp
  lldb/source/Symbol/TypeSystem.cpp
  lldb/source/Target/Process.cpp
  lldb/source/Target/StackFrame.cpp
  lldb/source/Target/Target.cpp
  lldb/source/Target/ThreadPlanTracer.cpp
  lldb/tools/lldb-test/lldb-test.cpp
  lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp
  lldb/unittests/Symbol/TestClangASTImporter.cpp
  lldb/unittests/Symbol/TestTypeSystemClang.cpp
  lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
  lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136650.472785.patch
Type: text/x-patch
Size: 174445 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20221102/acfa9eb4/attachment-0001.bin>


More information about the lldb-commits mailing list