Skip to content

Fix the Effective Access Level of package Declarations #69709

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 4 commits into from
Nov 10, 2023

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Nov 7, 2023

swiftc mis-compiles package declarations today because it reports the effective access level of package declarations as less than public. There are a bunch of places in the optimizer that are checking the effective access level against an upper bound of public, so a lot of code winds up internalized or optimized as though it were internal when it definitely is not.

Fixes rdar://118081829

swiftc mis-compiles package declarations today because it reports the effective access level of package declarations as less than public. There are a bunch of places in the optimizer that are checking the effective access level against an upper bound of public, so a lot of code winds up internalized or optimized as though it were internal when it definitely is not.

Fixes rdar://118081829
@CodaFi CodaFi requested a review from elsh November 7, 2023 22:57
@nkcsgexi
Copy link
Contributor

nkcsgexi commented Nov 7, 2023

Thank you for fixing this, @CodaFi !

@nkcsgexi nkcsgexi requested a review from xymus November 7, 2023 23:25
@nkcsgexi
Copy link
Contributor

nkcsgexi commented Nov 7, 2023

Could you add a test case that package decls have public symbols?

@CodaFi
Copy link
Contributor Author

CodaFi commented Nov 7, 2023

Sure thing. I was moving rather quickly - tests will follow shortly.

@CodaFi
Copy link
Contributor Author

CodaFi commented Nov 8, 2023

Existing tests are rather wonky on my machine.

@swift-ci smoke test

@CodaFi
Copy link
Contributor Author

CodaFi commented Nov 8, 2023

@swift-ci smoke test

@CodaFi
Copy link
Contributor Author

CodaFi commented Nov 8, 2023

@swift-ci test

Copy link
Contributor

@elsh elsh left a comment

Choose a reason for hiding this comment

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

Thanks for the fix and adding the tests!

@CodaFi CodaFi merged commit f93c66d into swiftlang:main Nov 10, 2023
@CodaFi CodaFi deleted the vulf-pack branch November 10, 2023 01:05
CodaFi pushed a commit to CodaFi/swift that referenced this pull request Nov 29, 2023
This accidentally started happening when I adjusted getEffectiveAccess to return `Public` for `Package` declarations in swiftlang#69709. As a result, the optimizer thought it had more opportunities to go after declarations that used to be opaque. Unfortunately, this resulted in a miscompile as the devirtualizer was able to look through now-serialized package (static) functions. In one specific instance, the optimizer created direct calls to hidden accessors instead of going through the dispatch thunk.
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