-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Avoid sharing the parent process's stdin handle to python on Windows + other Windows bat script fixes #15146
Avoid sharing the parent process's stdin handle to python on Windows + other Windows bat script fixes #15146
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems necessary, but it does mean we can't do emcc.bat < file.cpp
I assume? If so, documenting that at least might be a good idea.
I thou would need to add
On the other hand as long as this only effects windows I think they usage of stdin is probably less there .. |
c718466
to
1d37c9e
Compare
…ng python via emcc.bat script, to prevent a rare python deadlock hang.
Work around a Windows 7 batch script exit code issue. Work around a Windows Python spawn issue: https://bugs.python.org/issue34780
… statement (an if() statement would taint the 0 variable)
cad8916
to
28e26eb
Compare
Updated this PR to contain all the different changes to the batch scripts altogether. Realizing that not everyone will be affected by the Python issue, I opted to gate these workarounds behind env. vars so that people who are not affected will not lose out on features. |
@%CMD% %* | ||
@exit %ERRORLEVEL% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the /b
does this not exit the entire cmd.exe shell?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right, though unfortunately with the /b
flag that will not fix the Windows 7 issue. The /b
flag is used in the other part to avoid a goto
, which would reset the %errorlevel%
variable to zero.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So users of EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG
are opting into not being able to use these tools in a command shell, is that the idea? Maybe it would never make sense there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Sorry I should have read all of your above comments.. I see it mentions this there).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that is the case - when one enables EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG
, that will cause the shell to quit. For command line uses that would be quite undesirable, hence placing it under a separate workaround env. var.
I the old version of this script we don't call exit at all.. but somehow the exit code is still set correctly? (I guess because the emcc command is the very last one?). I wonder if it possible for the ":NORMAL" case to continue to work that way.. if we place it last in the script can we avoid calling exit at all maybe?
That way maybe |
Also maybe we would not longer need |
That is a very good suggestion. Updated to that form.
We do need that case, if we want to orthogonally support all combinations of |
Yes, normally |
Oh I see.. so that issue already exists today and is completely separate to the other one. Make sense. |
Does that mean that emcc.bat on windows 7 always returns success today? If windows 7 is so badly broken (and has been like that forever) how are not hearing more about this? |
No. We are seeing on Windows 7 when we spawn emcc.bat via tundra.exe, it will cause emcc.bat to always return exit code 1 (failed) back to tundra subprocess exit code. When emcc.bat is launched from cmdline as usual on Win 7, it does return 0 as usual. On Win8 and newer, this does not occur. |
Issue - emscripten-core/emscripten#15146 Emscripten added a workaround enabled by setting the environment variable - `EM_WORKAROUND_PYTHON_BUG_34780`.
* [wasm] Workaround a python bug which can cause em* scripts to hang Issue - emscripten-core/emscripten#15146 Emscripten added a workaround enabled by setting the environment variable - `EM_WORKAROUND_PYTHON_BUG_34780`. * [wasm] Wasm.Build.Tests - use a local copy of `dotnet` .. to avoid conflicting with other instances on helix. * don't log output from robocopy
This PR performs the following fixes:
EM_WORKAROUND_PYTHON_BUG_34780
that enables avoiding sharing the parent process's stdin handle to python when invoking python via emcc.bat script, to prevent a rare python deadlock hang bug https://bugs.python.org/issue34780EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG
that enables explicitly exiting the batch script with python errorlevel code, to work around a Windows 7 bad batch script exit code issue. We have not found a description of this bug on the web, but the issue that occurs is that on Windows 7, the invoked batch scripts return with a nonzero exit code, even if the python subprocess call was clean with exit code zero and the%ERRORLEVEL%
variable in the batch script itself was zero. This is possibly caused by the same python bug 34780 as above, but we have no confirmation about this. Therefore it is important to treat this separately because the "nuclear option" ofexit %ERRORLEVEL%
will exit the parent shell as well.setlocal
directive.:: comment
line is placed inside aif ()
block, it will be somehow parsed by the interpreter. E.g. if one would have a bat scriptthen running this bat script will print
These two error prints come from Windows bat script interpreter somehow parsing the comment strings as path names.
However, the following bat script
correctly prints out
so Windows parses comments somehow differently inside
if ()
sections. This means that we should avoid placing:: comment
s insideif ()
sections in these batch scripts.