Lldb crash when set breakpoint

I build the lldb to test something, and when I use 'breakpoint set' command, lldb crashed.

I use the tag 'swift-5.5.2-RELEASE' to build, here is the crash dump:

error: libarclite_iphoneos.a(arclite.o) failed to load objfile for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphoneos.a
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  lldb                     0x0000000100942c40 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  lldb                     0x00000001009421dc llvm::sys::RunSignalHandlers() + 128
2  lldb                     0x0000000100943504 SignalHandler(int) + 292
3  libsystem_platform.dylib 0x000000019b3944e4 _sigtramp + 56
4  LLDB                     0x0000000115fab2a8 swift::TypeChecker::conformsToProtocol(swift::Type, swift::ProtocolDecl*, swift::DeclContext*) + 52
5  LLDB                     0x0000000115fab2a8 swift::TypeChecker::conformsToProtocol(swift::Type, swift::ProtocolDecl*, swift::DeclContext*) + 52
6  LLDB                     0x0000000115f753d8 (anonymous namespace)::DeclChecker::visitBoundVariable(swift::VarDecl*) + 1064
7  LLDB                     0x0000000115f74cac void llvm::function_ref<void (swift::VarDecl*)>::callback_fn<(anonymous namespace)::DeclChecker::visitPatternBindingDecl(swift::PatternBindingDecl*)::'lambda'(swift::VarDecl*)>(long, swift::VarDecl*) + 44
8  LLDB                     0x0000000115f6b794 swift::ASTVisitor<(anonymous namespace)::DeclChecker, void, void, void, void, void, void>::visit(swift::Decl*) + 844
9  LLDB                     0x0000000115f6977c (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 224
10 LLDB                     0x0000000115f6dec4 (anonymous namespace)::DeclChecker::visitClassDecl(swift::ClassDecl*) + 356
11 LLDB                     0x0000000115f6977c (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 224
12 LLDB                     0x0000000115f6968c swift::TypeChecker::typeCheckDecl(swift::Decl*) + 104
13 LLDB                     0x0000000116008620 swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 164
14 LLDB                     0x00000001160097bc llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) + 380
15 LLDB                     0x000000011600958c llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckSourceFileRequest, (void*)0>(swift::TypeCheckSourceFileRequest const&) + 108
16 LLDB                     0x000000011600848c swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType) + 28
17 LLDB                     0x00000001154bbffc swift::CompilerInstance::forEachFileToTypeCheck(llvm::function_ref<void (swift::SourceFile&)>) + 144
18 LLDB                     0x00000001154bbf40 swift::CompilerInstance::performSema() + 76
19 LLDB                     0x00000001154c15a8 std::__1::error_code llvm::function_ref<std::__1::error_code (swift::SubCompilerInstanceInfo&)>::callback_fn<swift::ModuleInterfaceBuilder::buildSwiftModuleInternal(llvm::StringRef, bool, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >*, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >)::$_1::operator()() const::'lambda'(swift::SubCompilerInstanceInfo&)>(long, swift::SubCompilerInstanceInfo&) + 780
20 LLDB                     0x00000001154c8918 swift::InterfaceSubContextDelegateImpl::runInSubCompilerInstance(llvm::StringRef, llvm::StringRef, llvm::StringRef, swift::SourceLoc, llvm::function_ref<std::__1::error_code (swift::SubCompilerInstanceInfo&)>) + 2504
21 LLDB                     0x00000001154c1270 void llvm::function_ref<void ()>::callback_fn<swift::ModuleInterfaceBuilder::buildSwiftModuleInternal(llvm::StringRef, bool, std::__1::unique_ptr<llvm::MemoryBuffer, std::__1::default_delete<llvm::MemoryBuffer> >*, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >)::$_1>(long) + 120
22 LLDB                     0x00000001152e84c8 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 252
23 LLDB                     0x00000001152e85b4 RunSafelyOnThread_Dispatch(void*) + 52
24 LLDB                     0x000000011537a6d8 threadFuncSync(void*) + 16
25 libsystem_pthread.dylib  0x000000019b37d240 _pthread_start + 148
26 libsystem_pthread.dylib  0x000000019b378024 thread_start + 8
********************
Crash reproducer for lldb version 10.0.0 (git@github.com:apple/llvm-project.git revision c315411fac10439aa7a09dce976b5716af9f149c)
Swift version 5.5.2 (swift-5.5.2-RELEASE)

addtional info: my test app is build with Xcode 13.2.1

Hi Ray. Thanks for the report. Could you share a sample project where this error reproduces? Or the expression you were trying to evaluate?

Sorry it's our company project so I can't share it with you, and I didn't use any expressions to evaluate, I just launch the lldb, and use 'breakpoint set --file xx.swift --line xx' command.

I wonder the lldb version must match the swift version? The swift version of lldb that I build is 'Swift version 5.5.2 (swift-5.5.2-RELEASE)', and the Xcode lldb version is 'Swift version 5.5.2-dev'. And which branch match the versoin 'Swift version 5.5.2-dev', I didn't find it.

What happens if you add this setting to your ~/.lldbinit file:

settings set symbols.swift-module-loading-mode only-serialized

From the evidence given, I suspect there's a mismatch between the version compiler and the debugger. Did you compile the code with the Xcode swift compiler, or the swift compiler you built along with lldb? The crash is while building a swiftmodule from a swiftinterface. It could be that lldb can't load the swiftmodule because its embedded compiler doesn't match the compiler that produced the swiftmodule, and is falling back to "compiling" a swiftinterface.

You could enable some lldb logging to see if the logs tell you more. See help log enable.

You could also attach lldb to lldb and look at the variables to find out which swiftinterface is being built.

You're right, I compile the code with Xcode swift compiler, but use the custom build lldb to debug my code. I'll try your suggestions, thanks.

I add settings set symbols.swift-module-loading-mode only-serialized to ~/.lldbinit file, and lldb doesn't crash, but when I po some value, lldb report the error:

Cannot create Swift scratch context (couldn't load the Swift stdlib)

I think it's about the version. But I can't find the right source code version corresponding Xcode 13.2.1, I use the source code tag swift-5.5.2-RELEASE, It seems it's not the right commit.