public inbox for cygwin-xfree@sourceware.org
help / color / mirror / Atom feed
From: Michel Hummel <hummel.michel@gmail.com>
To: cygwin-xfree@cygwin.com
Subject: XWin crash after the launch of startkde on a remote Red Hat 5 machine
Date: Tue, 03 Aug 2010 07:55:00 -0000	[thread overview]
Message-ID: <AANLkTikbPe7y3rPk0LLT3+J61zEvR1Lf6Q=VPK8iEHhZ@mail.gmail.com> (raw)
In-Reply-To: <AANLkTikJdnM+_7z5qvrdyannbTUifMGodisQniJd6-GW@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4232 bytes --]

Hello,
I'm using cygwin on Microsoft Windows XP with XWin version :
sh-3.2# XWin.exe -version
Welcome to the XWin X Server
Vendor: The Cygwin/X Project
Release: 1.8.0.0 (10800000)
Build Date: 2010-04-02
Contact: cygwin-xfree@cygwin.com

I think I have found a bug in the XWin reset procedure which leads to
the start of two clipboard thread's and sometime to a crash of the X
server.

The crash can be produced by lauching startkde on a Red Hat 5 remote
machine (The crash should arrive after some minutes of work)
but the bug can simply be produced like this :

On my installation if I launch Xwin with this options :
XWin :0 -ac&
then I do
xsetroot -solid '#FFFF00'

After setting the color, Xwin launches its reset procedure because
there is no more client connected ( the server loses the color but it
is the normal comportment isn't it ?
http://sourceware.org/ml/cygwin-xfree/2002-01/msg00106.html)

The problem comes from the clipboard thread. In this example, when the
server launches its reset procedure, the clipboard is in state
"Launched" but is not in state "Started" (Boolean variable about
clipboard status, see file hw/xwin/winclipboardthread.c).

This particular status of the ClipboardThread during server reset is
normaly managed by two "if" statements :

* An "if" in the file hw/xwin/InitOutput.c disables the exit of the
clipboard thread in this state
Extract of the file hw/xwin/InitOutput.c (with line number) :

 169 winClipboardShutdown (void)
 170 {
 171   /* Close down clipboard resources */
 172   if (g_fClipboard && g_fClipboardLaunched && g_fClipboardStarted)
 173     {
 174       /* Synchronously destroy the clipboard window */
 175       if (g_hwndClipboard != NULL)
 176         {
 177           SendMessage (g_hwndClipboard, WM_DESTROY, 0, 0);
 178           /* NOTE: g_hwndClipboard is set to NULL in
winclipboardthread.c */
 179         }
 180       else
 181         return;
 182
 183       /* Wait for the clipboard thread to exit */
 184       pthread_join (g_ptClipboardProc, NULL);
 185
 186       g_fClipboardLaunched = FALSE;
 187       g_fClipboardStarted = FALSE;
 188
 189       winDebug ("winClipboardShutdown - Clipboard thread has exited.\n");
 190     }
 191 }

* An "if" statement in the file hw/xwin/winclipboardwrappers.c
prohibits the launch of clipboard thread if one is already Launched.
Extract of the file hw/xwin/winclipboardwrappers.c (with line number)
256   /* If the clipboard client has already been started, abort */
257   if (g_fClipboardLaunched)
258     {
259       ErrorF ("winProcEstablishConnection - Clipboard client already "
260               "launched, returning.\n");
261       return iReturn;
262     }


The problem is that the Boolean variables g_fClipboardLaunched and
g_fClipboardStarted are re-initialized by the server reset procedure
(function winInitializeGlobals of the file  hw/xwin/winglobals.c)
Extract of the file hw/xwin/winglobals.c (with line number)
128 /*
129  * Re-initialize global variables that are invalidated 130  * by a
server reset.
131  */
132
133 void
134 winInitializeGlobals (void)
135 {
136   g_dwCurrentThreadID = GetCurrentThreadId ();
137   g_hwndKeyboardFocus = NULL;
138 #ifdef XWIN_CLIPBOARD
139   g_fClipboardLaunched = FALSE;
140   g_fClipboardStarted = FALSE;
141   g_iClipboardWindow = None;
142   g_pClipboardDisplay = NULL;
143   g_atomLastOwnedSelection = None;
144   g_hwndClipboard = NULL;
145 #endif
146 }

The consequence of this Re-initialization in this particular situation
is that the clipboard thread is launched two times and sometimes leads
to a crash of the X server.
You can see the double launch of the clipboard thread at the end of
the attached log file Xwin.0.log ( 2 times the sentence :
winClipboardProc - XOpenDisplay () returned and successfully opened
the display. )

To fix this bug I purpose to remove the variables g_fClipboardLaunched
and g_fClipboardStarted of the "winInitializeGlobals (void)" function,
as their re-initializations are handled in in the files :
hw/xwin/InitOutput.c.

That what is doing the patch Attached to this email.

Regards,
Michel Hummel

[-- Attachment #2: XWin_winglobals_ClipboardThread.patch --]
[-- Type: application/octet-stream, Size: 570 bytes --]

diff -r -u -p /home/hummelm/xserver-cygwin-1.8.0-1//hw/xwin/winglobals.c ./hw/xwin/winglobals.c
--- /home/hummelm/xserver-cygwin-1.8.0-1//hw/xwin/winglobals.c	2010-04-02 11:15:26.000000000 +0200
+++ ./hw/xwin/winglobals.c	2010-06-29 14:12:54.572239300 +0200
@@ -136,8 +136,6 @@ winInitializeGlobals (void)
   g_dwCurrentThreadID = GetCurrentThreadId ();
   g_hwndKeyboardFocus = NULL;
 #ifdef XWIN_CLIPBOARD
-  g_fClipboardLaunched = FALSE;
-  g_fClipboardStarted = FALSE;
   g_iClipboardWindow = None;
   g_pClipboardDisplay = NULL;
   g_atomLastOwnedSelection = None;

[-- Attachment #3: XWin.0.log --]
[-- Type: application/octet-stream, Size: 5054 bytes --]

Welcome to the XWin X Server
Vendor: The Cygwin/X Project
Release: 1.8.0.0 (10800000)
Build Date: 2010-04-02

Contact: cygwin-xfree@cygwin.com
XWin was started with the following command line:

XWin -ac :0 

ddxProcessArgument - Initializing default screens
winInitializeDefaultScreens - primary monitor w 1280 h 1024
winInitializeDefaultScreens - native DPI x 96 y 96
winInitializeDefaultScreens - Returning
[ 16410.531] _XSERVTransSocketOpenCOTSServer: Unable to open socket for inet6
[ 16410.531] _XSERVTransOpen: transport open failed for inet6/PC-2118593:0
[ 16410.531] _XSERVTransMakeAllCOTSServerListeners: failed to open listener for inet6
[ 16410.812] winValidateArgs - g_iNumScreens: 1 iMaxConsecutiveScreen: 1
[ 16410.812] (II) xorg.conf is not supported
[ 16410.812] (II) See http://x.cygwin.com/docs/faq/cygwin-x-faq.html for more information
[ 16410.828] LoadPreferences: /home/hummelm/.XWinrc not found
[ 16410.828] LoadPreferences: Loading /etc/X11/system.XWinrc
[ 16410.828] LoadPreferences: Done parsing the configuration file...
[ 16410.828] winGetDisplay: DISPLAY=:0.0
[ 16410.828] winDetectSupportedEngines - Windows NT/2000/XP
[ 16410.843] winDetectSupportedEngines - DirectDraw installed
[ 16410.843] winDetectSupportedEngines - DirectDraw4 installed
[ 16410.843] winDetectSupportedEngines - Returning, supported engines 00000007
[ 16410.843] winSetEngine - Using Shadow DirectDraw NonLocking
[ 16410.843] winAdjustVideoModeShadowDDNL - Using Windows display depth of 32 bits per pixel
[ 16410.906] winFinishScreenInitFB - Masks: 00ff0000 0000ff00 000000ff
[ 16410.906] Screen 0 added at virtual desktop coordinate (1280,0).
[ 16410.906] MIT-SHM extension disabled due to lack of kernel support
[ 16410.937] XFree86-Bigfont extension local-client optimization disabled due to lack of shared memory support in the kernel
[ 16410.968] (II) AIGLX: Loaded and initialized /usr/lib/dri/swrast_dri.so
[ 16410.968] (II) GLX: Initialized DRISWRAST GL provider for screen 0
[ 16411.796] winPointerWarpCursor - Discarding first warp: 637 481
[ 16411.796] (--) 3 mouse buttons found
[ 16411.796] (--) Setting autorepeat to delay=500, rate=31
[ 16411.796] (--) winConfigKeyboard - Layout: "0000040C" (0000040c) 
[ 16411.796] (--) Using preset keyboard for "French (Standard)" (40c), type "4"
[ 16411.796] Rules = "base" Model = "pc105" Layout = "fr" Variant = "none" Options = "none"
[ 16471.687] winProcEstablishConnection - Hello
[ 16471.687] winInitClipboard ()
[ 16471.687] winProcEstablishConnection - winInitClipboard returned.
[ 16471.687] winClipboardProc - Hello
[ 16471.687] DetectUnicodeSupport - Windows NT/2000/XP
[ 16471.718] winGetDisplay: DISPLAY=:0.0
[ 16471.718] winClipboardProc - DISPLAY=:0.0
[ 16471.750] (II) xorg.conf is not supported
[ 16471.750] (II) See http://x.cygwin.com/docs/faq/cygwin-x-faq.html for more information
[ 16471.750] LoadPreferences: /home/hummelm/.XWinrc not found
[ 16471.750] LoadPreferences: Loading /etc/X11/system.XWinrc
[ 16471.750] LoadPreferences: Done parsing the configuration file...
[ 16471.750] winGetDisplay: DISPLAY=:0.0
[ 16471.750] winDetectSupportedEngines - Windows NT/2000/XP
[ 16471.765] winDetectSupportedEngines - DirectDraw installed
[ 16471.765] winDetectSupportedEngines - DirectDraw4 installed
[ 16471.765] winDetectSupportedEngines - Returning, supported engines 00000007
[ 16471.765] winSetEngine - Using Shadow DirectDraw NonLocking
[ 16471.812] winFinishScreenInitFB - Masks: 00ff0000 0000ff00 000000ff
[ 16471.812] Screen 0 added at virtual desktop coordinate (1280,0).
[ 16471.812] MIT-SHM extension disabled due to lack of kernel support
[ 16471.812] winClipboardProc - Could not open display, try: 1, sleeping: 4
[ 16471.843] XFree86-Bigfont extension local-client optimization disabled due to lack of shared memory support in the kernel
[ 16471.875] (II) AIGLX: Loaded and initialized /usr/lib/dri/swrast_dri.so
[ 16471.875] (II) GLX: Initialized DRISWRAST GL provider for screen 0
[ 16472.640] (--) 3 mouse buttons found
[ 16472.640] (--) Setting autorepeat to delay=500, rate=31
[ 16472.640] (--) winConfigKeyboard - Layout: "0000040C" (0000040c) 
[ 16472.640] (--) Using preset keyboard for "French (Standard)" (40c), type "4"
[ 16472.640] Rules = "base" Model = "pc105" Layout = "fr" Variant = "none" Options = "none"
[ 16473.328] _XSERVTransSocketUNIXAccept: accept() failed
[ 16473.328] winInitClipboard ()
[ 16473.328] winClipboardProc - Hello
[ 16473.328] winProcEstablishConnection - winInitClipboard returned.
[ 16473.328] DetectUnicodeSupport - Windows NT/2000/XP
[ 16473.328] winGetDisplay: DISPLAY=:0.0
[ 16473.328] winClipboardProc - DISPLAY=:0.0
[ 16473.343] winClipboardProc - XOpenDisplay () returned and successfully opened the display.
[ 16473.343] winClipboardProc - XOpenDisplay () returned and successfully opened the display.
[ 16516.375] winClipboardProc - winClipboardFlushWindowsMessageQueue trapped WM_QUIT message, exiting main loop.
[ 16516.375] winClipboardProc - XDestroyWindow succeeded.
[ 16516.390] winClipboardIOErrorHandler!


[-- Attachment #4: Type: text/plain, Size: 223 bytes --]

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://x.cygwin.com/docs/
FAQ:                   http://x.cygwin.com/docs/faq/

       reply	other threads:[~2010-08-03  7:55 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <AANLkTikJdnM+_7z5qvrdyannbTUifMGodisQniJd6-GW@mail.gmail.com>
2010-08-03  7:55 ` Michel Hummel [this message]
2010-08-06 12:55 ` Michel Hummel
2010-08-08 13:14   ` Jon TURNEY
2010-09-18 18:44     ` michel hummel
2010-09-20 13:59       ` Jon TURNEY
2010-09-20 14:49         ` Michel Hummel
2010-09-22  9:03           ` Michel Hummel
2010-09-22 14:30             ` Jon TURNEY
2010-09-22 17:11               ` XWin.exe parms wrapped by startwin.exe Fouts, Christopher
2010-09-23 12:39                 ` Jon TURNEY
2010-09-24  8:15               ` XWin crash after the launch of startkde on a remote Red Hat 5 machine Michel Hummel
2010-09-24 15:04                 ` Michel Hummel
2010-09-28 20:12                 ` Jon TURNEY
2010-09-28 21:28                   ` Jim Reisert AD1C
2010-09-29  8:59                   ` Michel Hummel
2010-09-29 14:05                     ` Michel Hummel
2010-10-31 16:59                       ` Jon TURNEY

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='AANLkTikbPe7y3rPk0LLT3+J61zEvR1Lf6Q=VPK8iEHhZ@mail.gmail.com' \
    --to=hummel.michel@gmail.com \
    --cc=cygwin-xfree@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).