[Bug 34930] New: Cygwin-compiled Hello World program couldn't display output
http://bugs.winehq.org/show_bug.cgi?id=34930 Bug #: 34930 Summary: Cygwin-compiled Hello World program couldn't display output Product: Wine Version: 1.7.6 Platform: x86 OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown AssignedTo: wine-bugs(a)winehq.org ReportedBy: Nachanon_Vetjasit(a)hotmail.com Classification: Unclassified I've recently found that console-based C program (even a simplest one shown below) that's compiled with Cygwin x86 1.7.25 (GCC 4.7.3) failed to display output properly in WINE. /* hello.c */ #include <stdio.h> int main() { printf("Hello World\n"); return 0; }
From Cygwin shell under Microsoft Windows XP SP3:
cygwin$ gcc -Wall -o hello.exe hello.c Under Debian GNU/Linux 5.0 "Lenny" i386: (I copied both hello.exe and cygwin1.dll to my Debian partition) $ wine hello.exe fixme:ntdll:NtSetInformationToken unimplemented class 4 fixme:ntdll:NtQueryInformationProcess (process=0xffffffff) Unimplemented information class: ProcessSessionInformation fixme:ntdll:NtQueryVolumeInformationFile 0xc0: volume info not supported fixme:ntdll:NtQueryVolumeInformationFile 0xc0: faking attribute info fixme:ntdll:NtQueryVolumeInformationFile 0xc0: faking attribute info $ Apart from FIXMEs, there is no "Hello World" printed out. Attached file contains source code above, the executable and cygwin1.dll. WINE: 1.7.6 (source) on Debian GNU/Linux 5.0 "Lenny" i386 Cygwin: cygwin1.dll 1.7.25 (x86) -- Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email Do not reply to this email, post in Bugzilla using the above URL to reply. ------- You are receiving this mail because: ------- You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=34930 --- Comment #1 from Nachanon Vetjasit <Nachanon_Vetjasit(a)hotmail.com> 2013-11-16 09:01:06 CST --- http://www.mediafire.com/?4f4vacdk3eazgzv This archive contains - hello world source code shown in the submission - cygwin-compiled hello world binary (x86) - cygwin1.dll 1.7.25 (x86) -- Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email Do not reply to this email, post in Bugzilla using the above URL to reply. ------- You are receiving this mail because: ------- You are watching all bug changes.
http://bugs.winehq.org/show_bug.cgi?id=34930 --- Comment #2 from Nachanon Vetjasit <Nachanon_Vetjasit(a)hotmail.com> 2013-11-16 09:04:14 CST --- But if I tried to redirect standard output/standard error stream something interesting happened: $ wine hello.exe 2>&1 | tee hello.log.txt fixme:ntdll:NtSetInformationToken unimplemented class 4 fixme:ntdll:NtQueryInformationProcess (process=0xffffffff) Unimplemented information class: ProcessSessionInformation fixme:ntdll:NtQueryVolumeInformationFile 0xc0: volume info not supported fixme:ntdll:NtQueryVolumeInformationFile 0xc0: faking attribute info fixme:ntdll:NtQueryVolumeInformationFile 0xc0: faking attribute info fixme:ntdll:NtQueryInformationFile Unsupported class (8) fixme:ntdll:NtQueryInformationFile Unsupported class (8) Hello World Application tried to create a window, but no driver could be loaded. The explorer process failed to start. $ "Hello World" got displayed, but some (unrelated?) error about windowing and WINE Explorer (?) popped up too. Even so, it should display correctly when there's no redirection present. -- Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email Do not reply to this email, post in Bugzilla using the above URL to reply. ------- You are receiving this mail because: ------- You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=34930 Richard Yao <ryao(a)gentoo.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ryao(a)gentoo.org --- Comment #3 from Richard Yao <ryao(a)gentoo.org> --- Both stderr and stdout are affected. Redirecting stderr of cygwin's echo.exe program will reveal an additional error message: /usr/bin/echo: write error: Bad file descriptor Running wineconsole and then executing the program inside the graphical interface works. It even works if you do `wineconsole --backend=user /path/to/echo.exe Hello World`, but for obvious reasons, the console emulator exits as soon as Hello World is printed. It does not work with you do `wineconsole --backend=curses /path/to/echo.exe Hello World`. Running wineconsole with WINEDEBUG=+console,+ntdll,+relay revaled that the two situations execute identically until KERNEL32.GetConsoleWindow is called. With ---backend=user, a non-zero value is returned. With --backend=curses, a zero value is returned. Afterward, the execution paths diverge. By the way, this still affects Wine 1.7.33. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=34930 Qian Hong <fracting(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |fracting(a)gmail.com --- Comment #4 from Qian Hong <fracting(a)gmail.com> --- Hello, As an workaround, you can try: $ wine wineconsole cmd inside the console, run:
hello.exe
This work for me. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=34930 --- Comment #5 from Qian Hong <fracting(a)gmail.com> --- (In reply to Richard Yao from comment #3)
Both stderr and stdout are affected. Redirecting stderr of cygwin's echo.exe program will reveal an additional error message:
/usr/bin/echo: write error: Bad file descriptor
Running wineconsole and then executing the program inside the graphical interface works. It even works if you do `wineconsole --backend=user /path/to/echo.exe Hello World`, but for obvious reasons, the console emulator exits as soon as Hello World is printed. It does not work with you do `wineconsole --backend=curses /path/to/echo.exe Hello World`. Running wineconsole with WINEDEBUG=+console,+ntdll,+relay revaled that the two situations execute identically until KERNEL32.GetConsoleWindow is called. With ---backend=user, a non-zero value is returned. With --backend=curses, a zero value is returned. Afterward, the execution paths diverge.
By the way, this still affects Wine 1.7.33.
oops, sorry, I didn't noticed that you already found it. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=34930 --- Comment #6 from Qian Hong <fracting(a)gmail.com> --- According to relay log: 0023:Call KERNEL32.GetStdHandle(fffffff6) ret=610299bf 0023:Ret KERNEL32.GetStdHandle() retval=00000017 ret=610299bf ... 0023:Call KERNEL32.GetFileType(0000001b) ret=610293bb 0023:Ret KERNEL32.GetFileType() retval=00000002 ret=610293bb 0023:Call KERNEL32.GetConsoleScreenBufferInfo(0000001b,0061aa16) ret=610293f7 0023:trace:console:GetConsoleScreenBufferInfo (0x1b,(80,150) (0,0) 15 (0,0-79,24) (80,25) 0023:Ret KERNEL32.GetConsoleScreenBufferInfo() retval=00000001 ret=610293f7 0023:Call KERNEL32.CloseHandle(0000001b) ret=61029853 0023:Ret KERNEL32.CloseHandle() retval=00000001 ret=61029853 So STDOUT (STD_OUTPUT_HANDLE:fffffff6 =>0000001b) is closed here. I'm looking into the below cygwin code: winsup/cygwin/dtable.cc: dtable::init_std_file_from_handle: 311 else if (GetConsoleScreenBufferInfo (handle, &buf) 312 || GetNumberOfConsoleInputEvents (handle, (DWORD *) &buf)) 313 { 314 /* Console I/O */ 315 if (myself->ctty > 0) 316 dev.parse (myself->ctty); 317 else 318 { 319 dev.parse (FH_CONSOLE); 320 CloseHandle (handle); 321 handle = INVALID_HANDLE_VALUE; 322 } 323 } Not sure why ctty is not positive here. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=34930 --- Comment #7 from Qian Hong <fracting(a)gmail.com> --- Created attachment 50682 --> https://bugs.winehq.org/attachment.cgi?id=50682 Hack: fill fake hwnd for wineconsole curses backend -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=34930 --- Comment #8 from Qian Hong <fracting(a)gmail.com> --- Created attachment 50685 --> https://bugs.winehq.org/attachment.cgi?id=50685 Hack: return fake console windows hwnd in GetConsoleWindow -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=34930 Qian Hong <fracting(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch, source, testcase --- Comment #9 from Qian Hong <fracting(a)gmail.com> --- Hi, Thanks for reporting the bug. Please try the attach two hacks. Richard, you are right, the reason is GetConsoleWindow returns NULL in wineconsole curses backend in your case. I'm not sure what is the best solution for this problem. There are three ways to spawn a Win32 process using Wine on Linux terminal. The first one is starting directly, like: $ wine date.exe In this case, it is not clear that if the parent process of echo.exe should be considered as a Windows console, it is also not clear that if we should return non NULL for GetConsoleWindow. Anyway, the attach hack "return fake console windows hwnd in GetConsoleWindow" should help in this case. The second one is starting from wineconsole, using --backend=curses, like: $ wineconsole --backend=curses date.exe (you might want to create a batch file like test.bat, and append "sleep.exe 5" after "date.exe" to see the result) In this case, current wineconsole curses doesn't create a new Window, which is correct by design, but maybe we can simply fill a fake hwnd so GetConsoleWindow won't be NULL, which will make the curses backend more like a Windows console. The attach hack "fill fake hwnd for wineconsole curses backend " works in this way. We can even try to create a fake hidden Window and emulate a bit more information if there is any application relies on it, but that's much more work. The third one is starting from wineconsole, using --backend=user, like: $ wineconsole --backend=user date.exe In this case, wineconsole create a new Window, and GetConsoleWindow already works. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=34930 Sebastian Lackner <sebastian(a)fds-team.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |sebastian(a)fds-team.de --- Comment #10 from Sebastian Lackner <sebastian(a)fds-team.de> --- Should be partially fixed by http://source.winehq.org/git/wine.git/commit/2100d3e1ec3e47194fb7076de30f1ac.... -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=34930 Qian Hong <fracting(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |FIXED --- Comment #11 from Qian Hong <fracting(a)gmail.com> --- (In reply to Sebastian Lackner from comment #10)
Should be partially fixed by http://source.winehq.org/git/wine.git/commit/ 2100d3e1ec3e47194fb7076de30f1acfe2b60bef.
Confirming the wineconsole curse backend part has been fixed. thanks Sebastian! Resolved as fixed for the wineconsole part, will create a new bug to track the pure Linux console part. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=34930 Sebastian Lackner <sebastian(a)fds-team.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |2100d3e1ec3e47194fb7076de30 | |f1acfe2b60bef -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=34930 --- Comment #12 from Qian Hong <fracting(a)gmail.com> --- A follow up of this bug for the pure Linux console issue has been reported as Bug 38640. As Sebastian Lackner pointed out in https://bugs.wine-staging.com/show_bug.cgi?id=290, it might be a WONTFIX/CANTFIX, feel free to add more details to the new bug. I have no enough idea for the new bug yet, will update once I have :) -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=34930 Alexandre Julliard <julliard(a)winehq.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED --- Comment #13 from Alexandre Julliard <julliard(a)winehq.org> --- Closing bugs fixed in 1.7.44. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=34930 Saulius K. <saulius2(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |saulius2(a)gmail.com -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
participants (1)
-
wine-bugs@winehq.org