Skip to content

[5.4] fix silent crash when output from compiler is too large #3482

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, 2021

Conversation

tomerd
Copy link
Contributor

@tomerd tomerd commented May 7, 2021

brings #3478 to 5.4

motivation: silent crashes, confused uers

changes:
* change the order in swiftCompilerOutputParser such that print the stdout happens before any parsing attenpts are made
* contraint the parsing attempts to output < 10k, since otherwise they struggle to complete

rdar://77558631
@tomerd
Copy link
Contributor Author

tomerd commented May 7, 2021

@swift-ci please test

@tomerd tomerd changed the title fix silent crash when output from compiler is too large (#3478) [5.4] fix silent crash when output from compiler is too large May 7, 2021
@tomerd tomerd self-assigned this May 10, 2021

// next we want to try and scoop out any errors from the output (if reasonable size, otherwise this will be very slow),
// so they can later be passed to the advice provider in case of failure.
if output.utf8.count < 1024 * 10 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the 8 MB limit calculated in some way, or is it arbitrarily chosen? I don't have an opinion either way. I'm just curious.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

base don experiments with SIL output in crashes. @abertelrud is working on a separate PR to fix this parsing logic and this will be removed then. this PR is focused on "damage control" given that this caused issues in 5.4

// next we want to try and scoop out any errors from the output (if reasonable size, otherwise this will be very slow),
// so they can later be passed to the advice provider in case of failure.
if output.utf8.count < 1024 * 10 {
let regex = try! RegEx(pattern: #".*(error:[^\n]*)\n.*"#, options: .dotMatchesLineSeparators)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this parsing of error messages be replaced by using TSCUtility.SerializedDiagnostics, which I think is more performant and less reliant on the error messages' structure/format staying unchanged?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah sorry I just saw that this PR is a cherry-pick of #3478, and my comment would've been more appropriate there, or in the form of a new PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@abertelrud is working on a separate PR to fix this parsing logic, this PR is focused on "damage control" given that this caused issues in 5.4

Copy link
Contributor

Choose a reason for hiding this comment

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

Using TSCUtility.SerializedDiagnostics is a great idea, and we should definitely adopt that across SwiftPM. That will be a larger effort than fixing this, also, linker diagnostics are unfortunately not yet part of the serialized diagnostics, so it wouldn't help this particular case. They are very source-code focused and currently (AFAIK) only emitted by Clang and Swiftc. But it's definitely where we should move to in SwiftPM, I believe, with tool-specific adapters that favor serialized diagnostics where supported, and that fall back on parsing stderr where we have to.

@tomerd tomerd merged commit 374cdb4 into swiftlang:release/5.4 May 14, 2021
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