Skip to content

Fix miscompilations for debugger because of resilience #78728

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

Merged
merged 1 commit into from
Jan 23, 2025

Conversation

augusto2112
Copy link
Contributor

This patch fixes two instances of the compiler embedded in LLDB miscompiling code for the debugger's expression evaluation, because of a combination of the debugger's access to private types and resilience, which would cause the generated code to access fields indirectly through resilience functions that were never emitted.

rdar://137876089

This patch fixes two instances of the compiler embedded in LLDB
miscompiling code for expression evaluation, because of a combination of
the debugger's access to private types and resilience, which would cause
the generated code to access fields indirectly through resilience functions
that were never emitted.

rdar://137876089
@augusto2112
Copy link
Contributor Author

@swift-ci test

@augusto2112
Copy link
Contributor Author

@adrian-prantl on #78486 you said that this should be testable but I'm not sure how? We'd somehow have to access a private type on a different module to emulate lldb's behavior, which I don't I don't think is possible (LLDB does that by overriding DebuggerClient, which of course we can't do here)?

@augusto2112
Copy link
Contributor Author

I'm adding some lldb tests though

@augusto2112
Copy link
Contributor Author

@swift-ci test

1 similar comment
@augusto2112
Copy link
Contributor Author

@swift-ci test

!classDecl->getASTContext().LangOpts.DebuggerSupport ||
methodAccess == AccessLevel::Public;
if (IGM.hasResilientMetadata(classDecl, ResilienceExpansion::Maximal) &&
shouldUseDispatchThunkIfInDebugger) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be tested by compiling Swift code to IR and passing -debugger-support?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that but it's not enough. To look up private classes LLDB implements the DebuggerClient interface, without that we can't write a test that can extend a non-public type in a different module, to emulate LLDB's behavior.

@adrian-prantl adrian-prantl self-requested a review January 21, 2025 21:57
@augusto2112
Copy link
Contributor Author

@swift-ci test Linux

@augusto2112 augusto2112 merged commit 683c02c into swiftlang:main Jan 23, 2025
5 checks passed
// level of the getter to decide whether to use a dispatch thunk for the
// debugger.
bool shouldUseDispatchThunkIfInDebugger =
!classDecl->getASTContext().LangOpts.DebuggerSupport ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IGM.Context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants