Skip to content

SIL: Fix a crash during access path verification #69799

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

Conversation

tshortli
Copy link
Contributor

The access path verification optimizer pass calls getStaticallyInitializedVariable(), which was written assuming that the given SILFunction would always have a valid return basic block. When the -unavailable-decl-optimization=stub option is passed to the frontend, though, any function generated for a declaration marked @available(*, unavailable) is rewritten to trap by calling a function that returns Never. Therefore the rewritten functions do not have return blocks and passing these functions to getStaticallyInitializedVariable() would result in the compiler invoking undefined behavior.

Resolves rdar://118281508

@tshortli tshortli enabled auto-merge November 12, 2023 00:49
The access path verification optimizer pass calls
`getStaticallyInitializedVariable()`, which was written assuming that the given
`SILFunction` would always have a valid return basic block. When the
`-unavailable-decl-optimization=stub` option is passed to the frontend, though,
any function generated for a declaration marked `@available(*, unavailable)` is
rewritten to trap by calling a function that returns `Never`. Therefore the
rewritten functions do not have return blocks and passing these functions to
`getStaticallyInitializedVariable()` would result in the compiler invoking
undefined behavior.

Resolves rdar://118281508
@tshortli tshortli force-pushed the access-path-verification-unavailable-stub-crash branch from bfa6fa6 to da3af76 Compare November 12, 2023 17:48
@tshortli
Copy link
Contributor Author

@swift-ci please smoke test

@tshortli tshortli merged commit 09688ab into swiftlang:main Nov 12, 2023
@tshortli tshortli deleted the access-path-verification-unavailable-stub-crash branch November 12, 2023 20:51
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.

1 participant