Skip to content

Fix a crash during lookup of an operator with package acl #66155

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
May 26, 2023
Merged

Conversation

elsh
Copy link
Contributor

@elsh elsh commented May 25, 2023

Type-checking an operator requires look up of all of its decls regardless of
which access modifier is used before filtering. If one of them is a package
decl in an imported module that was built with package-name, but the use site
of the operator decl is in a module that is not built with package-name, it
currently crashes as it tries to access package context of the use site, which
is null. This PR checks if both decl site and use site have package contexts
before accessing the package name property, otherwise return false to be
filtered out.
Resolves rdar://108961906

@elsh
Copy link
Contributor Author

elsh commented May 25, 2023

@swift-ci smoke test

Type-checking an operator requires look up of all of its decls regardless of
which access modifier is used before filtering. If one of them is a package
decl in an imported module that was built with package-name, but the use site
of the operator decl is in a module that is not built with package-name, it
currently crashes as it tries to access package context of the use site, which
is null. This PR checks if both decl site and use site have package contexts
before accessing the package name property, otherwise return false to be filtered
out.

Resolves rdar://108961906
@elsh
Copy link
Contributor Author

elsh commented May 25, 2023

@swift-ci smoke test

@elsh elsh changed the title Fix a crash during an operator type check with package acl Fix a crash during lookup of an operator with package acl May 26, 2023
@elsh elsh merged commit ff696c4 into main May 26, 2023
@elsh elsh deleted the es-crash branch May 26, 2023 18:52
Copy link
Contributor

@xymus xymus left a comment

Choose a reason for hiding this comment

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

That was an interesting one to reproduce!

elsh added a commit that referenced this pull request May 30, 2023
[5.9] Fix a crash during lookup of an operator with package acl
Description: Type-checking an operator requires look up of all of its decls regardless of which access modifier is used before filtering. If one of them is a package decl in an imported module that was built with package-name, but the use site of the operator decl is in a module that is not built with package-name, it currently crashes as it tries to access package context of the use site, which is null. The change in this PR checks if both decl site and use site have package contexts before accessing the package name property, otherwise return false to be filtered out. This PR also includes a check of source file kind before showing diagnostics to ensure that errors are not shown if source is interface as interface does not include package symbols.
Risk: Low. It adds a null check on package context before accessing package name.
Original PR: Fix a crash during lookup of an operator with package acl #66155
Reviewed By: @tshortli @xedin @xymus
Testing: Added a test that ensures coverage of the affected flow
Resolves: rdar://108961906
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.

4 participants