https://bugs.winehq.org/show_bug.cgi?id=39793
Bug ID: 39793 Summary: Starcraft freezes when starting a Direct Cable Connection game Product: Wine Version: 1.7.46 Hardware: x86 OS: Linux Status: NEW Severity: normal Priority: P2 Component: ntdll Assignee: wine-bugs@winehq.org Reporter: alexhenrie24@gmail.com Distribution: ---
To reproduce: 1. Add yourself to the dialout (Ubuntu) or uucp (Arch) user group. 2. Log out and log back in. 3. In Starcraft, click Multiplayer, Direct Cable Connection, Ok.
The problem is that Starcraft attempts to detect which serial port is connected by sending a burst of data on all ports COM1 through COM8. On Linux, COM1 through COM4 default to ttyS0 through ttyS3, but even though the device files exist, rarely do all of them correspond to actual physical devices. So, Starcraft hangs forever waiting for the write to complete successfully.
A patchset that fixes this bug is available at https://github.com/alexhenrie/wine/commits/master
First reported at https://appdb.winehq.org/objectManager.php?sClass=version&iId=149&iT...
https://bugs.winehq.org/show_bug.cgi?id=39793
--- Comment #1 from Alex Henrie alexhenrie24@gmail.com --- Created attachment 53275 --> https://bugs.winehq.org/attachment.cgi?id=53275 [PATCH] ntdll: Do a device check before returning a default serial port name.
This patch is the same as the one I sent to wine-patches, except that the comment no longer says that /dev/ttyS0 through /dev/ttyS4 are _always_ present on Linux. It turns out that the number of serial port device files depends on the distribution: Arch creates 4 by default, Ubuntu creates 32. In reality, I think the most that I have ever seen on a motherboard is 2.
https://bugs.winehq.org/show_bug.cgi?id=39793
--- Comment #2 from Alex Henrie alexhenrie24@gmail.com --- There is a workaround for this bug: Add 8250.nr_uarts=<n> to the Linux kernel command line, where <n> is the number of serial ports physically present on your motherboard. This will make Linux create the exact right number of serial port device files.
See http://tldp.org/HOWTO/Serial-HOWTO-15.html#ss15.3 for details.
https://bugs.winehq.org/show_bug.cgi?id=39793
Alex Henrie alexhenrie24@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |erich.e.hoover@wine-staging | |.com, michael@fds-team.de, | |sebastian@fds-team.de
--- Comment #3 from Alex Henrie alexhenrie24@gmail.com --- Since it doesn't look like this patch is going to be accepted into mainline Wine, how would you feel about including it in Wine Staging?
https://bugs.winehq.org/show_bug.cgi?id=39793
--- Comment #4 from Bruno Jesus 00cpxxx@gmail.com --- In the patch you are adding a conditional dependency on termios.h but when using the struct termios you are not checking with an ifdef so if termios.h does not exist the patch would not compile, I'm away from Linux so I can't check but I believe this is one reason the patch may have been marked as pending.
https://bugs.winehq.org/show_bug.cgi?id=39793
--- Comment #5 from Sebastian Lackner sebastian@fds-team.de --- (In reply to Alex Henrie from comment #3)
Since it doesn't look like this patch is going to be accepted into mainline Wine, how would you feel about including it in Wine Staging?
Not sure if this is distribution specific, but at least here, opening a existent but unused COM port fails, even without this patch. Hacky test:
--- snip --- #include <windows.h> #include <stdio.h> int main() { FILE *fp = fopen("COM1", "w+"); printf("%s\n", fp ? "successfully opened" : "failed to open"); } --- snip ---
Could you provide more details under which circumstances the issue occurs?
https://bugs.winehq.org/show_bug.cgi?id=39793
--- Comment #6 from Sebastian Lackner sebastian@fds-team.de --- (In reply to Bruno Jesus from comment #4)
In the patch you are adding a conditional dependency on termios.h but when using the struct termios you are not checking with an ifdef so if termios.h does not exist the patch would not compile, I'm away from Linux so I can't check but I believe this is one reason the patch may have been marked as pending.
This is most likely fine, the function is part of POSIX, and also used at various other places without #ifdef check.
https://bugs.winehq.org/show_bug.cgi?id=39793
--- Comment #7 from Alex Henrie alexhenrie24@gmail.com --- Created attachment 53320 --> https://bugs.winehq.org/attachment.cgi?id=53320 Test program that demonstrates the problem
The attached program replicates what Starcraft is doing. Because WriteError fails with ERROR_NOT_READY, the event in the OVERLAPPED structure never fires and the program stalls.
If COM1 is a real serial port, this program will print:
Waiting for the write operation to successfully complete... The write operation finished successfully.
If COM1 is not a real serial port, this program will print:
The device is not ready. Waiting for the write operation to successfully complete...
The tests in the function read_file_test in dlls/ntdll/tests/file.c indicate that ReadFile does not fire events if there is an error, which strongly suggests that Wine's identical behavior for WriteFile is also correct. Still, it would be nice to have more tests specifically for WriteFile.
During boot, Windows checks (by executing NTDETECT) which COM ports are physically present. If COM1 was not detected at boot, CreateFile("COM1", ...) fails, avoiding the problem with Starcraft. By mimicking this behavior, Wine can avoid the problem with Starcraft too.
https://bugs.winehq.org/show_bug.cgi?id=39793
Alex Henrie alexhenrie24@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch
https://bugs.winehq.org/show_bug.cgi?id=39793
Sebastian Lackner sebastian@fds-team.de changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |STAGED Staged patchset| |https://github.com/wine-com | |pholio/wine-staging/tree/ma | |ster/patches/ntdll-Serial_P | |ort_Detection
https://bugs.winehq.org/show_bug.cgi?id=39793
André H. nerv@dawncrow.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |nerv@dawncrow.de
--- Comment #8 from André H. nerv@dawncrow.de --- (In reply to Sebastian Lackner from comment #6)
(In reply to Bruno Jesus from comment #4)
In the patch you are adding a conditional dependency on termios.h but when using the struct termios you are not checking with an ifdef so if termios.h does not exist the patch would not compile, I'm away from Linux so I can't check but I believe this is one reason the patch may have been marked as pending.
This is most likely fine, the function is part of POSIX, and also used at various other places without #ifdef check.
Still it Linux only. When it's a posix function it should also work for BSD and such, right? Or one would find a compatible solution there too...
https://bugs.winehq.org/show_bug.cgi?id=39793
--- Comment #9 from Sebastian Lackner sebastian@fds-team.de --- (In reply to André H. from comment #8)
Still it Linux only. When it's a posix function it should also work for BSD and such, right? Or one would find a compatible solution there too...
I assume it would work, but haven't verified it myself. Even if thats not the case, I'm pretty sure there are also other ways to implement this feature.
https://bugs.winehq.org/show_bug.cgi?id=39793
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |focht@gmx.net Staged patchset|https://github.com/wine-com |https://github.com/wine-sta |pholio/wine-staging/tree/ma |ging/wine-staging/tree/mast |ster/patches/ntdll-Serial_P |er/patches/ntdll-Serial_Por |ort_Detection |t_Detection
--- Comment #10 from Anastasius Focht focht@gmx.net --- Hello folks,
likely still present, updating some fields.
$ wine --version wine-3.4
Regards
https://bugs.winehq.org/show_bug.cgi?id=39793
tokktokk fdsfgs@krutt.org changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |fdsfgs@krutt.org
https://bugs.winehq.org/show_bug.cgi?id=39793
Aida Jonikienė aidas957@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |aidas957@gmail.com
--- Comment #11 from Aida Jonikienė aidas957@gmail.com --- The tcgetattr() function seems to be present on FreeBSD, OpenBSD, Android (and likely macOS) too so it seems safe enough to use it without an ifdef