Hello,

It seems freemind still has some issues with it.  I'm however surprised
it doesn't have issues even without accessibility enabled:  XInitThreads
is never called at all, but stracing shows that writev()/recvmsg()
is really done on the X11 socket concurrently in various threads...
libX11 is not supposed to be threadsafe when XInitThreads is not called
before anything else.  Probably it happens to work fine enough with
non-threaded applications, but only because X calls happen to get
serialized enough.  Freemind does use threads, so it is then not simple,
and enabling accessibility probably simply has changed a bit the order
in which threads get to make X calls, leading to a situation where
concurrency does matter.

In the attached patch, I have added XInitThreads() calls before
XOpenDisplay() calls, and now freemind starts fine on my box.

I'm really surprised that this has not posed problems before: making X
calls from different threads can really only pose problems...

Samuel
--- openjdk/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
+++ openjdk/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
@@ -816,6 +816,7 @@ awt_init_Display(JNIEnv *env, jobject th
         }
     }
 
+    XInitThreads();
     dpy = awt_display = XOpenDisplay(NULL);
 #ifdef NETSCAPE
     sigprocmask(SIG_SETMASK, &oldset, NULL);
--- openjdk/jdk/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c
+++ openjdk/jdk/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c
@@ -427,6 +427,7 @@ SplashInitPlatform(Splash * splash) {
     //XSetErrorHandler(HandleError);
 //    XSetIOErrorHandler(HandleIOError);
     XSetIOErrorHandler(NULL);
+    XInitThreads();
     splash->display = XOpenDisplay(NULL);
     if (!splash->display) {
         splash->isVisible = -1;
--- openjdk/jdk/src/solaris/native/sun/xawt/XlibWrapper.c
+++ openjdk/jdk/src/solaris/native/sun/xawt/XlibWrapper.c
@@ -82,6 +82,7 @@ JNIEXPORT jlong JNICALL Java_sun_awt_X11
 {
     Display *dp;
     AWT_CHECK_HAVE_LOCK();
+    XInitThreads();
     dp  =  XOpenDisplay((char *) jlong_to_ptr(display_name));
 
     return ptr_to_jlong(dp);

Reply via email to