Skip to content

[CodeCompletion] Fix ASAN failure when completing in parameter packs #65837

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 14, 2023

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented May 10, 2023

Whe completing in parameter packs, we were calling getParameterAt with Res.FuncDeclRef. But the substitution map in Res.FuncDeclRef contained type variables that were allocated in the constraint system’s arena. And that arena had been freed when we call this from deliverResults.

The fix is to compute the optional parameters in advance in sawSolutionImpl

rdar://109093909

@ahoppen ahoppen requested a review from xedin May 10, 2023 20:52
@ahoppen ahoppen requested review from bnbarham and rintaro as code owners May 10, 2023 20:52
@ahoppen
Copy link
Member Author

ahoppen commented May 10, 2023

@swift-ci Please smoke test

/// Indicies are based on the parameters in \c FuncTy. Note that the number
/// of parameters in \c FuncTy and \c FuncD is different when a parameter
/// pack has been exploded.
std::vector<bool> DeclParamIsOptional;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe OptionalParams and you can use llvm::BitVector?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea 👍🏽

@ahoppen ahoppen force-pushed the ahoppen/fix-asan-failure branch 2 times, most recently from 6ada5d6 to 9c6d31f Compare May 10, 2023 21:30
@ahoppen
Copy link
Member Author

ahoppen commented May 10, 2023

@swift-ci Please smoke test

Whe completing in parameter packs, we were calling `getParameterAt` with `Res.FuncDeclRef`. But the substitution map in `Res.FuncDeclRef` contained type variables that were allocated in the constraint system’s arena. And that arena had been freed when we call this from `deliverResults`.

The fix is to compute the optional parameters in advance in `sawSolutionImpl`

rdar://109093909
@ahoppen ahoppen force-pushed the ahoppen/fix-asan-failure branch from 9c6d31f to 9dd87e9 Compare May 10, 2023 22:24
@ahoppen
Copy link
Member Author

ahoppen commented May 10, 2023

@swift-ci Please smoke test

@ahoppen ahoppen merged commit 1db0947 into swiftlang:main May 14, 2023
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