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-8491] In a method from an extension conforming to NSObjectProtocol (or another protocol that conforms to it) lldb can't reconstruct the objc ivar part of self #4491

Closed
swift-ci opened this issue Aug 8, 2018 · 8 comments
Assignees
Labels
bug Something isn't working LLDB for Swift

Comments

@swift-ci
Copy link

swift-ci commented Aug 8, 2018

Previous ID SR-8491
Radar rdar://problem/43057063
Original Reporter Milenkovic (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

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

md5: c52999df9aeb103dd514eb07c0609777

Issue Description:

If a protocol requires conforming to UIViewControllerTransitioningDelegate, all LLDB activities in the protocols methods stop working, most often with EXC_BAD_ACCESS but various other errors were also met. In the attached file a line exists that says

print("breakpoint here")

where if you put a breakpoint, and tried printing anything that protocol requires (example provides a "testVar: Int") you would reproduce the issue.

@belkadan
Copy link

belkadan commented Aug 8, 2018

@swift-ci create

@swift-ci
Copy link
Author

swift-ci commented Aug 8, 2018

Comment by Jim Ingham (JIRA)

The problem seems to be conforming to NSObjectProtocol (which UIViewControllerTransitioningDelegate conforms to). You can repro the bug using just NSObjectProtocol.

Not everything is broken, "po self" works and if you add locals expression evaluation with them in the extension function works. But it looks like when you make an NSObject derived class (which already conforms to NSObjectProtocol) also conform to NSObjectProtocol by another path, we lost the NSObject-ness of the class. For instance if you do "frame var self" you won't see any of the ivars for UIViewController. Since we don't know about those ivars, we're not going to print or access the ones on the Swift side correctly.

@swift-ci
Copy link
Author

swift-ci commented Aug 8, 2018

Comment by Jovan (JIRA)

jingham@apple.com (JIRA User) sorry I meant everything regarding the protocol itself. So maybe you could adjust the bug to be more precise, but the issue is that the debugger is rendered pretty much completely useless since you can't use p/po {any var that protocol guarantees is there} nor e { any method that protocol guarantees is there }. The variables view is also acting as if all the variables are not yet initialized. I also haven't found a reasonable workaround, the best so far is to go a step back in the stack and print that same variable from another context.

@dcci
Copy link
Mannequin

dcci mannequin commented Aug 8, 2018

OK, this looks like a type reconstruction bug (thanks to Jim for triaging!), so it's something I'll look at.

@swift-ci
Copy link
Author

swift-ci commented Aug 8, 2018

Comment by Jim Ingham (JIRA)

Milenkovic (JIRA User) I wasn't criticizing the bug, your reproducer was easy to use, so you did you job correctly. I wasn't trying to minimize the effects, just trying to be precise about what they were. Sorry if I gave the wrong impression.

For context: since self in this extension method is only known as "an entity conforming to a protocol", it doesn't have a statically known type, and going just by the debug information we would have no way to access its actual fields. So we have to reconstruct the actual type with all the ivars the protocol knows nothing about from the runtime. That turns out to be one of the trickier parts of the swift debugger. The fact that it is the ivars of the reconstructed type that are wrong, and not other aspects of the context we're stopped in, tells us that this is a type reconstruction bug, (and allows me to palm it off on Davide 😉)

@swift-ci
Copy link
Author

swift-ci commented Aug 8, 2018

Comment by Jovan (JIRA)

jingham@apple.com (JIRA User) no no I didn't get that impression, my intention was simply to point out that you should feel free to adjust the bug to be better with the info you got from your debugging to make the job easier for the assignee. I basically knew right away that I didn't provide the minimal bug because I don't know about the debugger and objc runtime so didn't have that much time to waste on it, so any improvement would be welcome. I also prefer tickets assigned to me to have this info up there where it belongs instead of in the comments, so it's also personal preference 👍

@dcci
Copy link
Mannequin

dcci mannequin commented Dec 13, 2018

Fixed on master.

@belkadan
Copy link

Issues should go to "Resolved" when they're fixed; only the originator should close them!

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

No branches or pull requests

2 participants