[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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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