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

Add msvctricks.exe to replace problematic wine-msvc.bat #68

Merged
merged 2 commits into from
May 22, 2023

Conversation

huangqinjin
Copy link
Contributor

https://learn.microsoft.com/en-us/troubleshoot/windows-client/shell-experience/command-line-string-limitation
The maximum length of the string that you can use at the command prompt is 8191 characters.

Below are tests I have done.

  1. echo "%var_of_length_8191%"
  • Windows CMD: Outputs "The input line is too long."
  • Wine8.7 CMD: Crashed.
  1. echo "%var_of_length_8192%"
  • Windows CMD: Outputs "".
  • Wine8.7 CMD: Crashed.
  1. echo "!var_of_length_8191!"
  • Windows CMD: This line is silently ignored and outputs nothing.
  • Wine8.7 CMD: Outputs all 8191 characters.
  1. echo "!var_of_length_8192!"
  • Windows CMD: Outputs "".
  • Wine8.7 CMD: Outputs first 8191 characters.

Even I split the argument string into multiple variables with smaller length, wine crashes when total arguments are more than 16350 characters.

The reliable way is to use a native Win32 executable replacing the bat file. Now the arguments can have more than 32700 characters (CreateProcess accepts at most 32767 characters).

The name msvctricks follows winetricks.

…limitation of CMD

https://learn.microsoft.com/en-us/troubleshoot/windows-client/shell-experience/command-line-string-limitation
The maximum length of the string that you can use at the command prompt is 8191 characters.

This change is based on the test result of [3] below.

1. echo "%var_of_length_8191%"
- Windows CMD: Outputs "The input line is too long."
- Wine8.7 CMD: Crashed.

2. echo "%var_of_length_8192%"
- Windows CMD: Outputs "".
- Wine8.7 CMD: Crashed.

3. echo "!var_of_length_8191!"
- Windows CMD: This line is silently ignored and outputs nothing.
- Wine8.7 CMD: Outputs all 8191 characters.

4. echo "!var_of_length_8192!"
- Windows CMD: Outputs "".
- Wine8.7 CMD: Outputs first 8191 characters.
@huangqinjin huangqinjin mentioned this pull request May 18, 2023
@huangqinjin huangqinjin force-pushed the msvctricks branch 3 times, most recently from b9881b6 to 0440cd6 Compare May 18, 2023 15:41
Copy link
Owner

@mstorsjo mstorsjo left a comment

Choose a reason for hiding this comment

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

This looks good overall, and thanks for the very quick followup! I can't test it right now, but hopefully I can give it a spin within a few days.

@@ -137,3 +137,17 @@ for arch in x86 x64 arm arm64; do
cat msvcenv.sh | sed 's/ARCH=.*/ARCH='$arch/ > bin/$arch/msvcenv.sh
done
rm msvcenv.sh

host=x64
Copy link
Owner

Choose a reason for hiding this comment

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

Nice of you to split out the host arch here! FWIW I do have an experimental branch for running on aarch64 (see the branch arm64 in this repo), so for that branch it's easy to pick the right host arch here too.

if [ -d /proc/$$/fd ]; then
if ! $HAS_MSVCTRICKS; then
WINEDEBUG=-all wine64 "$EXE" "${ARGS[@]}" 2> >(sed -e "$unixify_path" >&2) | sed -e "$unixify_path"
exit $PIPESTATUS
Copy link
Owner

Choose a reason for hiding this comment

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

Exellent that this can gracefully degrade to the original form of this script, that's much appreciated! (And I see that it's necessary for bootstrapping building the msvctricks executable anyway.)

@mstorsjo
Copy link
Owner

This seems to work fine for me, thanks!

@mstorsjo mstorsjo merged commit 2146cbf into mstorsjo:master May 22, 2023
@huangqinjin huangqinjin deleted the msvctricks branch May 22, 2023 09:33
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.

2 participants