Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-15236] Intermittent behavior while debugging swift application with LLDB #4304

Open
swift-ci opened this issue Sep 23, 2021 · 1 comment
Open
Labels
bug LLDB for Swift

Comments

@swift-ci
Copy link

@swift-ci swift-ci commented Sep 23, 2021

Previous ID SR-15236
Radar rdar://problem/83455926
Original Reporter lcsmarcal (JIRA User)
Type Bug
Environment

Xcode 13 | Apple Swift version 5.5 (swiftlang-1300.0.31.1 clang-1300.0.29.1)

macOS BigSur

Additional Detail from JIRA
Votes 0
Component/s LLDB for Swift
Labels Bug
Assignee None
Priority Medium

md5: 0d8ab96f9e0821fda8683b3779febed0

Issue Description:

Related to Intermittent behavior while debugging swift application with LLDB

We use Buck as our swift application build system and we are getting some intermittent behaviors while debugging the app with LLDB.

When stopping at some breakpoints and running a po with some instance value of self we're getting this:

(lldb) po
self.customView error: Couldn't realize type of self.

Searching for some more information about the error with log enable lldb types expr that's what I get for this case:

== [UserExpression::Evaluate] Parsing expression self.customView == SwiftASTContextForExpressions::GetModule("Swift") SwiftUserExpression::ScanContext() [SUE::SC] Compilation unit is swift SwiftASTContext("CoolApplication")::ReconstructType("$s26CoolModulePresentation0A18MenuViewControllerCD") SwiftASTContext("CoolApplication")::ReconstructType("$s26CoolModulePresentation0A18MenuViewControllerCD") -- found in the negative cache could not get type metadata from address 4628814032 : an unknown failure occurred SwiftASTContext("CoolApplication")::ReconstructType("$s26CoolModulePresentation0A18MenuViewControllerCD") SwiftASTContext("CoolApplication")::ReconstructType("$s26CoolModulePresentation0A18MenuViewControllerCD") -- found in the negative cache [SUE::SC] Containing class name: CoolModulePresentation.CoolMenuViewController Parsing the following code: extension $__lldb_context { @LLDBDebuggerFunction @available(iOS 14.5, *) final func $__lldb_wrapped_expr_0(_ $__lldb_arg : UnsafeMutablePointer<Any>) { do { /*__LLDB_USER_START__*/ self.customView /*__LLDB_USER_END__*/ } catch (let __lldb_tmp_error) { var $__lldb_error_result = __lldb_tmp_error } ... (thousand lines of loading/linking every application module) ... SwiftASTContext("CoolApplication")::ReconstructType("$s26CoolModulePresentation0A18MenuViewControllerCD") SwiftASTContext("CoolApplication")::ReconstructType("$s26CoolModulePresentation0A18MenuViewControllerCD") -- found in the negative cache SwiftASTContextForExpressions::ReconstructType("$s26CoolModulePresentation0A18MenuViewControllerCD") SwiftASTContextForExpressions::ReconstructType("$s26CoolModulePresentation0A18MenuViewControllerCD") -- not cached, searching SwiftASTContextForExpressions::SwiftDWARFImporterDelegate::lookupValue("CoolMenuViewController") SwiftASTContext("CoolApplication")::SwiftDWARFImporterDelegate::lookupValue("CoolMenuViewController") thousands of ...SwiftDWARFImporterDelegate::lookupValue("CoolMenuViewController") on each application module

After some clean builds with no change in the codebase or build process, finally get some successful response:

(lldb) po self.customView <SomeCoolModulePresentation.MenuView: 0x7fbea0883fa0; frame = (0 0; 0 0); layer = <CALayer: 0x600002f65e40>>

Lldb types expr log:

== [UserExpression::Evaluate] Parsing expression self.customView == SwiftASTContextForExpressions::GetModule("Swift") SwiftUserExpression::ScanContext() [SUE::SC] Compilation unit is swift SwiftASTContext("CoolApplication")::ReconstructType("$s26SomeCoolModulePresentation0A18MenuViewControllerCD") SwiftASTContext("CoolApplication")::ReconstructType("$s26SomeCoolModulePresentation0A18MenuViewControllerCD") -- found in the positive cache [self 0x7fa00a27a000] might have a dynamic type [self 0x7fa00a27a000] has a new dynamic type SomeCoolModulePresentation.MenuViewController [SUE::SC] Containing class name: SomeCoolModulePresentation.MenuViewController Parsing the following code: extension $__lldb_context { @LLDBDebuggerFunction @available(iOS 14.5, *) final func $__lldb_wrapped_expr_3(_ $__lldb_arg : UnsafeMutablePointer<Any>) { do { /*__LLDB_USER_START__*/ self.customView /*__LLDB_USER_END__*/ } catch (let __lldb_tmp_error) { var $__lldb_error_result = __lldb_tmp_error } (thousand lines of loading/linking every application module) -- EXPR evaluation generated raw sil -- -- EXPR evaluation generated canonical sil -- -- EXPR evaluation generated IR -- Registering JITted Functions: Function: s26CoolModulePresentation0A18MenuViewControllerC14__lldb_expr_10E03$__g9_wrapped_H2_4yySpyypGF at 0x16be209c0. Function: __swift_destroy_boxed_opaque_existential_0 at 0x16be20a80. Function: $sSSWOh at 0x16be20ab0. Registering JIIted Symbols: == [UserExpression::Evaluate] Executing expression == IRMemoryMap::Malloc process_sp=0x7fa0f50d7a18, process_sp->CanJIT()=true, process_sp->IsAlive()=true IRMemoryMap::Malloc (39, 0x8, 0x3, eAllocationPolicyMirror) -> 0x16bca2ed0 EntityVariable::Materialize [address = 0x16bca2ed0, m_variable_sp = self] SwiftASTContextForExpressions::ReconstructType("$s26SomeCoolModulePresentation0A18MenuViewControllerCD") ... SwiftASTContextForExpressions::ReconstructType("$s26SomeCoolModulePresentation0A18MenuViewControllerCD") -- found in the positive cache SwiftASTContextForExpressions::ReconstructType("$s26SomeCoolModulePresentation0A16MenuViewProtocol_pD") ... SwiftASTContextForExpressions::ReconstructType("$s26SomeCoolModulePresentation0A16MenuViewProtocol_pD") -- found in the positive cache [$R1 0x7fa021f93200] might have a dynamic type

After cleaning the caches/derived data and running a new build the problem returned to appear. My limited knowledge about swift and lldb integration doesn't let me figure out what's different between those two cases.

The app codebase is Swift with some pre-built third-party libs (swift, obj-c, c++). To deal with Buck relative paths and be able to set breakpoints we're using some settings set target.source-map.

We're not generating dsym files to debug, only using object files embedded DWARF (only generating dsyms to symbolicate crashes). But, by generating dsym files we're getting a different error output:

(lldb) po self.customView error: Couldn't lookup symbols: direct field offset for SomeCoolModulePresentation.CoolMenuViewController.customView : SomeCoolModulePresentation.CoolMenuViewProtocol

A sample project that reproduces the issue is available here

@typesanitizer
Copy link

@typesanitizer typesanitizer commented Sep 23, 2021

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug LLDB for Swift
Projects
None yet
Development

No branches or pull requests

2 participants