Skip to content

[5.0] Fix lookupDirect() use-after-scope bugs #20603

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

Conversation

beccadax
Copy link
Contributor

Cherry-picking the ASAN fix from #20557 to swift-5.0-branch.

@eeckstein We might close this without merging it since we're planning to branch again soon, but if not, we can push this PR forward.


In #7530, NominalTypeDecl::lookupDirect() started returning TinyPtrVector instead of ArrayRef. Unfortunately, some callees assigned its return value to a variable explicitly declared to be an ArrayRef; C++ happily converted the TinyPtrVector to an ArrayRef and then treated the TinyPtrVector as out-of-scope, so the ArrayRef would now point to an out-of-scope stack object.

This PR should fix ASan stack-use-after-scope test failures whose backtraces include one of:

  • CSGen.cpp:3511
  • CastOptimizer.cpp:333
  • CastOptimizer.cpp:375

There may still be other ASan failures after this PR. There should not be any normal test failures.

Resolves rdar://46031343.

In swiftlang#7530, NominalTypeDecl::lookupDirect() started returning TinyPtrVector instead of ArrayRef so that it wouldn’t be returning a pointer into a mutable data structure. Unfortunately, some callees assigned its return value into an ArrayRef; C++ happily converted the TinyPtrVector to an ArrayRef and then treated the TinyPtrVector as out-of-scope, so the ArrayRef would now point to an out-of-scope object. Oops.
@eeckstein
Copy link
Contributor

@swift-ci test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 4a40a6e

@eeckstein eeckstein merged commit 10a1c04 into swiftlang:swift-5.0-branch Nov 15, 2018
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