Skip to content

[AutoDiff] Plumb witness derivative generic signatures through SILGen. #40063

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 2 commits into from
Nov 8, 2021

Conversation

rxwei
Copy link
Contributor

@rxwei rxwei commented Nov 5, 2021

When SILGenWitnessTable creates a decl ref for the witness of a derivative function requirement, it is using the requirement's derivative generic signature in the resulting witness decl ref. This is wrong because the witness may have a different derivative generic signature than the requirement, leading to a crash. This bug was never discovered because GSB's dark magic made it "just work", until requirement machine.

The fix is to store the matched witness derivative generic signature in Witness during type checking, and during witness table generation, use the witness' generic signature to create a witness decl ref.

Also brings back #39505 by reverting the revert (#40057), now that the blocking issue was fixed.

Resolves rdar://84716758, rdar://84213107 and rdar://84987079.

@rxwei rxwei marked this pull request as ready for review November 5, 2021 08:09
@rxwei
Copy link
Contributor Author

rxwei commented Nov 5, 2021

@swift-ci please test

@rxwei
Copy link
Contributor Author

rxwei commented Nov 5, 2021

Since this PR contains a revert-of-revert, see ca4a645 for the diff specific to this fix.

Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

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

Thanks!

rxwei added 2 commits November 5, 2021 10:28
When SILGenWitnessTable creates a decl ref for the witness of a derivative function requirement, it is using the requirement's derivative generic signature in the resulting witness decl ref. This is wrong because the witness may have a different derivative generic signature than the requirement, leading to a crash. This bug was never discovered because GSB's dark magic made it "just work", until requirement machine.

The fix is to store the matched witness derivative generic signature in `Witness` during type checking, and during witness table generation, use the witness' generic signature to create a witness decl ref.

Resolves rdar://84716758, rdar://84213107 and rdar://84987079.
…aught by RequirementMachine""

This reverts commit 2629654.
@rxwei
Copy link
Contributor Author

rxwei commented Nov 5, 2021

@swift-ci please smoke test

@rxwei
Copy link
Contributor Author

rxwei commented Nov 5, 2021

@swift-ci please smoke test macos

@rxwei rxwei merged commit efb3a49 into swiftlang:main Nov 8, 2021
@rxwei rxwei deleted the rdar84716758 branch November 8, 2021 21:32
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.

2 participants