https://bugs.winehq.org/show_bug.cgi?id=51813
Bug ID: 51813 Summary: python fatal error redirecting stdout to file Product: Wine Version: 6.16 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs@winehq.org Reporter: xantares09@hotmail.com Distribution: ArchLinux
python exits with a fatal error when the output is redirected to a file
$ wget https://www.python.org/ftp/python/3.9.5/python-3.9.5-embed-win32.zip $ unzip python-3.9.5-embed-win32.zip $ wine python -c 'print("hello world")' > out.txt wine: created the configuration directory '/home/devel/.wine' ... wine: configuration in L"/home/devel/.wine" has been updated. Fatal Python error: init_sys_streams: can't initialize sys standard streams Python runtime state: core initialized OSError: [WinError 6] Invalid handle
Current thread 0x000000d4 (most recent call first): <no Python frame>
whereas it succeeds on stdout or /dev/null: $ wine python -c 'print("hello world")' hello world
I also tried python 3.8.6 and wine 6.15/6.14 without luck
see also topic https://forum.winehq.org/viewtopic.php?f=8&t=33992
https://bugs.winehq.org/show_bug.cgi?id=51813
--- Comment #1 from xantares xantares09@hotmail.com --- curiously it works through tee:
$ wine python -c 'print("hello world")' | tee > out.txt
https://bugs.winehq.org/show_bug.cgi?id=51813
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download, source CC| |austinenglish@gmail.com
https://bugs.winehq.org/show_bug.cgi?id=51813
Bernhard Übelacker bernhardu@mailbox.org changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |bernhardu@mailbox.org
--- Comment #2 from Bernhard Übelacker bernhardu@mailbox.org --- Created attachment 71237 --> https://bugs.winehq.org/attachment.cgi?id=71237 Workaround for redirection at linux side.
As far as I see does python query GetFileType for the handle from stdin which returns in the redirected case FILE_TYPE_DISK. Therefore it looks like python calls GetFileInformationByHandle and expects this to succeed.
In the case of a redirection created by cmd in native or wine this works as expected. But GetFileInformationByHandle fails if the redirection is done at linux side because fd->unix_name gets not set.
Attached patch should demonstrate the issue and possible workaround.
https://bugs.winehq.org/show_bug.cgi?id=51813
--- Comment #3 from Bernhard Übelacker bernhardu@mailbox.org --- Created attachment 71238 --> https://bugs.winehq.org/attachment.cgi?id=71238 GetFileInformationByHandle test program with some test outputs.
https://bugs.winehq.org/show_bug.cgi?id=51813
xantares xantares09@hotmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Version|6.16 |7.22
https://bugs.winehq.org/show_bug.cgi?id=51813
--- Comment #4 from xantares xantares09@hotmail.com ---
I submitted the patch on gitlab:
https://gitlab.winehq.org/wine/wine/-/merge_requests/1626
https://bugs.winehq.org/show_bug.cgi?id=51813
Eric Pouech eric.pouech@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |eric.pouech@gmail.com Ever confirmed|0 |1 Status|UNCONFIRMED |ASSIGNED Assignee|wine-bugs@winehq.org |eric.pouech@gmail.com
--- Comment #5 from Eric Pouech eric.pouech@gmail.com --- Created attachment 73605 --> https://bugs.winehq.org/attachment.cgi?id=73605 alternative patch
could you test this alternative patch? - we can do better than returning an empty BY_HANDLE_FILE_INFORMATION buffer - and doesn't require heuristics to return empty buffer
https://bugs.winehq.org/show_bug.cgi?id=51813
--- Comment #6 from xantares xantares09@hotmail.com --- your patch fixes the issue, I close my MR and let you submit it
https://bugs.winehq.org/show_bug.cgi?id=51813
--- Comment #7 from xantares xantares09@hotmail.com --- new MR:
https://gitlab.winehq.org/wine/wine/-/merge_requests/1665
hope it gets there for the next version
https://bugs.winehq.org/show_bug.cgi?id=51813
xantares xantares09@hotmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |bunglehead@gmail.com
https://bugs.winehq.org/show_bug.cgi?id=51813
temp82@luukku.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |temp82@luukku.com
--- Comment #8 from temp82@luukku.com --- (In reply to xantares from comment #7)
new MR:
https://gitlab.winehq.org/wine/wine/-/merge_requests/1665
hope it gets there for the next version
fixed?
cde092dd35463fff95a22f27256f6fe5fb06e1c6
https://bugs.winehq.org/show_bug.cgi?id=51813
--- Comment #9 from xantares xantares09@hotmail.com --- no, seems its not merged because they did not agree yet
https://bugs.winehq.org/show_bug.cgi?id=51813
Joel Holdsworth joel@airwebreathe.org.uk changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |joel@airwebreathe.org.uk
https://bugs.winehq.org/show_bug.cgi?id=51813
--- Comment #10 from Joel Holdsworth joel@airwebreathe.org.uk --- This bug is a duplicate of #46070
https://bugs.winehq.org/show_bug.cgi?id=46070
https://bugs.winehq.org/show_bug.cgi?id=51813
--- Comment #11 from Eric Pouech eric.pouech@gmail.com --- (In reply to xantares from comment #9)
no, seems its not merged because they did not agree yet
does it still happen with wine-9.0-rc1? (a better implemen of what has been proposed in #5 should be in)
https://bugs.winehq.org/show_bug.cgi?id=51813
--- Comment #12 from Joel Holdsworth joel@airwebreathe.org.uk --- In my testing, still a problem:
$ wine --version wine-9.0-rc1 $ wine python.exe -c 'print("Hello World")' > out.txt 007c:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005 007c:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005 007c:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005 007c:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005 007c:fixme:wineusb:query_id Unhandled ID query type 0x5. 007c:fixme:wineusb:query_id Unhandled ID query type 0x5. 007c:fixme:wineusb:query_id Unhandled ID query type 0x5. 007c:fixme:wineusb:query_id Unhandled ID query type 0x5. 007c:fixme:wineusb:query_id Unhandled ID query type 0x5. Fatal Python error: init_sys_streams: can't initialize sys standard streams Python runtime state: core initialized OSError: [WinError 6] Invalid handle
Current thread 0x00000024 (most recent call first): <no Python frame>
As a workaround, I have cherry-picked your fix into my branch: https://gitlab.winehq.org/epo/wine/-/commit/cde092dd35463fff95a22f27256f6fe5...
For other readers: This patch fixes the issue in kernelbase by removing unnecessary call to NtQueryInformationFile with FileAllInformation in GetFileInformationByHandle, which fails to retrieve the name (FileNameInformation) of the pipe-file. Instead it queries FileBaicInformation, FileStandardInformation and FileInternalInformation which provide sufficient information without failing.
Alternatively, there is also this patch: https://www.winehq.org/pipermail/wine-devel/2020-September/174029.html
This patch solves the issue in wineserver implementing NtQueryInformationFile FileNameInformation for pipes.
https://bugs.winehq.org/show_bug.cgi?id=51813
--- Comment #13 from Joel Holdsworth joel@airwebreathe.org.uk ---
(a better implemen of what has been proposed in #5 should be in)
I don't see any change to GetFileInformationByHandle. It still uses FileAllInformation.
https://bugs.winehq.org/show_bug.cgi?id=51813
--- Comment #14 from Eric Pouech eric.pouech@gmail.com --- (In reply to Joel Holdsworth from comment #13)
(a better implemen of what has been proposed in #5 should be in)
I don't see any change to GetFileInformationByHandle. It still uses FileAllInformation.
sorry, looks like I updated wrong bug entry. Nothing has changed here.
https://bugs.winehq.org/show_bug.cgi?id=51813
Bernhard Übelacker bernhardu@mailbox.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |1b0d8428dfc13b0fa5ea7d576df | |ef7aaf8a8c927 Resolution|--- |FIXED Status|ASSIGNED |RESOLVED
--- Comment #15 from Bernhard Übelacker bernhardu@mailbox.org --- $ wine python -c 'print("hello world")' > out.txt $ cat out.txt hello world $
Got fixed by: https://gitlab.winehq.org/wine/wine/-/commit/1b0d8428dfc13b0fa5ea7d576dfef7a... (And the three commits before.)
https://bugs.winehq.org/show_bug.cgi?id=51813
Nikolay Sivov bunglehead@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC|bunglehead@gmail.com |
https://bugs.winehq.org/show_bug.cgi?id=51813
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #16 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 9.3.
https://bugs.winehq.org/show_bug.cgi?id=51813
Michael Stefaniuc mstefani@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |9.0.x