Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Avoid using non-UTF-8 encoded argv more often#36590

Merged
dnfield merged 2 commits intoflutter:mainfrom
dnfield:tester_args
Oct 5, 2022
Merged

Avoid using non-UTF-8 encoded argv more often#36590
dnfield merged 2 commits intoflutter:mainfrom
dnfield:tester_args

Conversation

@dnfield
Copy link
Contributor

@dnfield dnfield commented Oct 4, 2022

Should fix flutter/flutter#112819

I have not tested this on a windows machine though. @sealesj would you be able to kick off a LED run with this patched in for one of your failing windows tests?

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

// Builds a |CommandLine| from the usual argc/argv.
//
// First checks if CommandLineFromPlatform returns a value, to avoid using an
// argv that is not provided as UTF-8.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

tester_main.cc uses this method, and now will pick up the UTF-8 encoded args on windows.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will break embedders who provide argc and argv explicitly.

Copy link
Contributor

Choose a reason for hiding this comment

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

Here

command_line = fml::CommandLineFromArgcArgv(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would mean we ignore the specified argc/argv on Windows and instead use the platform based method. I'm not really clear on how that's used today, but I suspect that embedders on Windows doing this are currently broken unless they're already using this API.

I suppose this could be a problem if the embedder is specifying values for argc/argv that weren't already passed in to the process though...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll refactor this to a separate method though to avoid disrupting the embedder API.

@dnfield
Copy link
Contributor Author

dnfield commented Oct 4, 2022

The test for this is in the linked bug.

@jason-simmons
Copy link
Member

The declaration for CommandLineFromPlatform must be moved above CommandLineFromArgcArgv

Otherwise LGTM

Verified that flutter test passes with this patch when run on Windows from a non-ASCII directory path.

@sealesj
Copy link
Contributor

sealesj commented Oct 4, 2022

Kicked off and tried to patch in both the gerrit utf-8 and this PR. I think I did it correctly, build is here: https://chromium-swarm.appspot.com/task?id=5dbce228851c7310

@dnfield
Copy link
Contributor Author

dnfield commented Oct 4, 2022

@jason-simmons - I rearranged the methods

@chinmaygarde - I added a new method and updated all the callsites except embedder.cc and one unit test explicitly testing the old method.

@dnfield dnfield requested a review from chinmaygarde October 5, 2022 16:38
@dnfield dnfield merged commit 3ea6871 into flutter:main Oct 5, 2022
@dnfield dnfield deleted the tester_args branch October 5, 2022 19:03
@dnfield
Copy link
Contributor Author

dnfield commented Oct 5, 2022

Ahh that task is trying to pull from the framework instead of the engine, so it won't work.

@dnfield
Copy link
Contributor Author

dnfield commented Oct 5, 2022

@sealesj - once this rolls through to the framework you should be able to try again.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disable Third Party Customer Test Temporarily

4 participants