Skip to content

[5.3][Parser/libSyntax] Avoid doing lookup for a previous parsed node when we are in backtracking mode #31718

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

akyrtzi
Copy link
Contributor

@akyrtzi akyrtzi commented May 11, 2020

Cherry-pick of #31685 for 5.3.

  • Explanation: Fixes a crash during SwiftSyntax incremental re-parsing that was found by the stress tester. The incremental parse was re-using previously parsed nodes while the parser was backtracking for property body parsing, which was violating some invariants of the libSyntax parsing mechanism. The change fixes this and also reduces parser backtracking until the accessor introducer, and not for the whole property body.

  • Scope of issue: Primarily affects SwiftSyntax usage with a minor and safe change to how property bodies are parsed.

  • Origination: Unclear. I suspect this has been an issue for a while.

  • Risk: Low. Changes are scoped to SwiftSyntax and to the parsing of property bodies.

  • Testing: Added regression tests.

  • Reviewer: Rintaro Ishizaki (@rintaro)

Resolves rdar://57679731

akyrtzi added 2 commits May 11, 2020 15:58
… we are in backtracking mode

This both addresses a crash during incremental re-parse (rdar://57679731) and generally avoids violating invariants for interacting with the parser library.
…ssor introducer

Previously it was backtracking for the duration of the whole property body which was preventing re-use of previously parsed nodes for incremental re-parsing.
@akyrtzi akyrtzi requested a review from a team as a code owner May 11, 2020 23:02
@akyrtzi
Copy link
Contributor Author

akyrtzi commented May 11, 2020

@swift-ci Please test

@akyrtzi akyrtzi added the r5.3 label May 11, 2020
@akyrtzi
Copy link
Contributor Author

akyrtzi commented May 12, 2020

@swift-ci please nominate

@akyrtzi
Copy link
Contributor Author

akyrtzi commented May 12, 2020

windows error is unrelated:

mt.exe : general error c101008d: Failed to write the updated manifest to the resource of file "dispatch_apply.exe". Access is denied.

@akyrtzi akyrtzi merged commit 220cde2 into swiftlang:release/5.3 May 12, 2020
@akyrtzi akyrtzi deleted the 5.3-libsyntax-incremental-parse-unreachable-fix branch May 12, 2020 05:46
@AnthonyLatsis AnthonyLatsis added swift 5.3 🍒 release cherry pick Flag: Release branch cherry picks labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants