-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
libnative uses CreateProcessA on windows #13815
Comments
Made an attempt at it (no tests yet). I did some manual testing on Windows and it looks like the current working directory and environment variables are being encoded correctly. However, the arguments are still showing garbage (encoded as UTF8 but with zeroes after every byte). Edit 1: Found the source of the problem: Edit 2: Changed to |
Nice work! Feel free to lump it all together as 1 PR, but separate commits for separate changes would be nice. |
Thanks! Do you have any suggestions on how I should write the tests? Testing |
I'd recommend writing a |
Here's a preliminary test that copies itself into a subdirectory with a non-ASCII name and then runs it as a child process. The parent process also adds an environment variable and an argument, both containing non-ASCII characters. The child process makes sure all the strings are intact. It works fine when compiled and executed manually (on both Debian and Windows), but not with the test runner. On both Debian and Windows the test fails due to missing symbols. I'm looking into this but don't have an explanation/solution yet. |
Nice job, that looks great! You're likely seeing problems due to being unable to find the dynamic library dependencies. You're overriding the dynamic loader path environment variable to nothing, so all the libraries cannot be found. You can probably get around it by compiling statically, using |
It would also probably be best to use |
That's what I originally thought too, so I made sure to append to the existing environment variables. However, the error still occurs. I'll use |
I think the reason why the library can't be found is because the test runner adds a relative path to the environment variables. But, in any case, using static linking works. (Sorry for the spam; didn't realize "Issue" is a special word on GitHub.) |
- Use Unicode-aware versions of `CreateProcess` (Fixes #13815) and `Get/FreeEnvironmentStrings`. - Includes a helper function `os::win32::as_mut_utf16_p`, which does the same thing as `os::win32::as_utf16_p` except the pointer is mutable. - Fixed `make_command_line` to handle Unicode correctly. - Tests for the above.
It should use CreateProcessW to properly encode running binaries with utf8 names.
Needs tests to be accompanied with the change.
cc #9822, I can mentor this
The text was updated successfully, but these errors were encountered: