https://bugs.winehq.org/show_bug.cgi?id=46211
Bug ID: 46211 Summary: Please delay X11 initialization until needed by the application in order to avoid spurious X error message Product: Wine Version: 3.0.3 Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: enhancement Priority: P2 Component: winex11.drv Assignee: wine-bugs@winehq.org Reporter: vincent-wine@vinc17.net Distribution: ---
Wine should delay X11 initialization until it knows that X is needed by the application. Otherwise one can get a spurious error message such as "Invalid MIT-MAGIC-COOKIE-1 key" (in the past from Xlib, now from libxcb) while X11 is actually not needed.
When Wine is used in scripts, e.g. for software testing (GNU MPFR in my case) in such an environment, the error message can yield issues when parsing the output.
I initially reported this bug in the Debian BTS: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=914822
Note 1: Bug 2972 was about a similar issue: a spurious Xlib error message when DISPLAY is not set. In my case, this is about a DISPLAY value that is no longer valid because the X server has shut down in the meantime (I recall that X11 is not needed for my tests, so that this shouldn't yield any failure). Thus this is a bit different. Redirecting stderr to a file as suggested in bug 2972 (before it was fixed) may not be a solution as real error messages on stderr can provide useful information and one may want to keep it together with normal output.
Note 2: Since bug 2972 has been fixed, a workaround is to unset DISPLAY for the tests (e.g. with "TESTS_ENVIRONMENT = env -u DISPLAY" in tests/Makefile.am), as one knows that DISPLAY is useless. Still, I think that if DISPLAY is set, X11 initialization should be delayed until needed.
Note 3: The problem was made worse by the fact the error message does not end with a newline character. This is what actually broke the parsing in my case. I reported this bug there: https://gitlab.freedesktop.org/xorg/lib/libx11/issues/80