[go: nahoru, domu]

Skip to content
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

[tool] when writing to openssl as a part of macOS/iOS code-signing, flush the stdin stream before closing it #150120

Conversation

andrewkolos
Copy link
Contributor
@andrewkolos andrewkolos commented Jun 12, 2024

Fixes #100584. Might help #137184.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@andrewkolos andrewkolos added the tool Affects the "flutter" command-line tool. See also t: labels. label Jun 12, 2024
@github-actions github-actions bot added the platform-ios iOS applications specifically label Jun 12, 2024
@jmagman

This comment was marked as resolved.

@andrewkolos

This comment was marked as resolved.

@andrewkolos andrewkolos marked this pull request as draft June 12, 2024 17:32
@flutter-dashboard

This comment was marked as outdated.

@andrewkolos andrewkolos force-pushed the dont-crash-tool-if-stdin-pipe-to-openssl-breaks branch from c870693 to 338c6b8 Compare June 21, 2024 17:29
@andrewkolos

This comment was marked as resolved.

stdin: opensslProcess.stdin,
line: signingCertificateStdout,
onError: (Object? error, _) {
throwToolExit('Failed to write to openssl process. Error: $error');
Copy link
Member
@christopherfujino christopherfujino Jun 21, 2024

Choose a reason for hiding this comment

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

Is this actionable by the user? We usually throw a tool exit if either the user provided invalid inputs or the state of their machine is in some bad state. This might legitimately be a bug in tool assumptions though, right?

Also, I wonder if the fact that we were synchronously closing this after we call .write() (but maybe before the write happened) is why this was crashing in the first place. If that is the case, this change should solve that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this actionable by the user? We usually throw a tool exit if either the user provided invalid inputs or the state of their machine is in some bad state. This might legitimately be a bug in tool assumptions though, right?

Great catch. I think I went on autopilot here. I've since replaced this with an Exception (code).

Also, I wonder if the fact that we were synchronously closing this after we call .write() (but maybe before the write happened) is why this was crashing in the first place. If that is the case, this change should solve that.

This is certainly possible. As you pointed out, Process.writeToStdinGuarded should protect us from this going forward.

Comment on lines +238 to +240
onError: (Object? error, _) {
throw Exception('Unexpected error when writing to openssl: $error');
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If this ends up becoming a pattern (it very much probably will), we may want to consider creating like a writeToStdinUnsafe method that accepts something like a message or taskDescription. This new method would then throw a custom exception type from that.

@andrewkolos andrewkolos changed the title [tool] instead of crashing, exit to tool if we are unable to write to openssl [tool] when writing to openssl as a part of macOS/iOS code-signing, flush the stdin stream before closing it Jun 24, 2024
@andrewkolos andrewkolos marked this pull request as ready for review June 25, 2024 06:00
Copy link
Member
@christopherfujino christopherfujino left a comment

Choose a reason for hiding this comment

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

a few nits, but LGTM

Comment on lines 295 to 297
stdin.flush().then((_) {
completer.complete();
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not merging this yet because we probably should have a .onError call here.

@andrewkolos andrewkolos force-pushed the dont-crash-tool-if-stdin-pipe-to-openssl-breaks branch from d895b26 to 515a5c9 Compare June 28, 2024 00:38
@andrewkolos
Copy link
Contributor Author
andrewkolos commented Jun 28, 2024

Heya @christopherfujino, I've reset your review status since I've made some non-trivial changes since your approval. For your convenience, here's the diff of what has changed.

Copy link
Member
@christopherfujino christopherfujino left a comment

Choose a reason for hiding this comment

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

LGTM

@andrewkolos andrewkolos added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 28, 2024
@auto-submit auto-submit bot merged commit 28ff595 into flutter:master Jun 28, 2024
128 checks passed
@andrewkolos andrewkolos added the cp: stable cherry pick this pull request to stable release candidate branch label Jun 28, 2024
flutteractionsbot pushed a commit to flutteractionsbot/flutter that referenced this pull request Jun 28, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 29, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 29, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 30, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 1, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Jul 1, 2024
flutter/flutter@651a17d...99bb2ff

2024-07-01 engine-flutter-autoroll@skia.org Roll Flutter Engine from 0d93da7e2fe1 to b57a044ed10f (1 revision) (flutter/flutter#151082)
2024-06-30 engine-flutter-autoroll@skia.org Roll Flutter Engine from ad1343cfb99e to 0d93da7e2fe1 (9 revisions) (flutter/flutter#151062)
2024-06-29 jason-simmons@users.noreply.github.com Reduce the depth used in a test that applies finders to deep widget trees (flutter/flutter#151049)
2024-06-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from f828363d03ff to ad1343cfb99e (3 revisions) (flutter/flutter#151016)
2024-06-29 32538273+ValentinVignal@users.noreply.github.com Add test for segmented_button.0.dart (flutter/flutter#150676)
2024-06-29 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#151022)
2024-06-29 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#150827)
2024-06-28 engine-flutter-autoroll@skia.org Roll Flutter Engine from 2f7e9ab27493 to f828363d03ff (3 revisions) (flutter/flutter#151013)
2024-06-28 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 3.25.10 to 3.25.11 (flutter/flutter#151012)
2024-06-28 andrewrkolos@gmail.com [tool] when writing to openssl as a part of macOS/iOS code-signing, flush the stdin stream before closing it (flutter/flutter#150120)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC camillesimon@google.com,rmistry@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
victorsanni pushed a commit to victorsanni/flutter that referenced this pull request Jul 8, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App cp: stable cherry pick this pull request to stable release candidate branch platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[flutter_tools] "SocketException: Write failed (OS Error: Broken pipe, errno = 32)" during flutter create
3 participants