On 11/24/2012 06:02 PM, Michael Meeks wrote:
Sorry to bother you; just visiting some friends at Munich hosting a
hack-fest; and they have an interesting problem with OpenJDK. It -seems-
that even though we initialise X with XInitThreads - before Java gets
involved and all has worked well for a long time; that (as of recently)
we fight over the (apparently global?) XSetErrorHandler and that causes
a nice crash :-)
#0 JNU_CallStaticMethodByName (env=0x0, hasException=0x0, class_name=0x7a3fa571
"sun/awt/X11/XToolkit", name=0x7a3fa55e "globalErrorHandler", signature=0x7a3fa558 "(JJ)I")
at ../../../src/share/native/common/jni_util.c:209
#1 0x7a3ca216 in ToolkitErrorHandler (dpy=0x808b1b0, event=0xbfff835c) at
../../../src/solaris/native/sun/xawt/XlibWrapper.c:1115
#2 0x440c8acb in _XError (dpy=0x808b1b0, rep=0xab53cc0) at ../../src/XlibInt.c:1583
#3 0x440c589d in handle_error (dpy=0x808b1b0, err=0xab53cc0, in_XReply=0) at
../../src/xcb_io.c:212
#4 0x440c58f7 in handle_response (dpy=0x808b1b0, response=0xab53cc0, in_XReply=0) at
../../src/xcb_io.c:324
#5 0x440c63e8 in _XEventsQueued (dpy=0x808b1b0, mode=1) at ../../src/xcb_io.c:363
#6 0x440b7118 in XEventsQueued (dpy=0x808b1b0, mode=1) at ../../src/Pending.c:43
#7 0x47dace8f in DisplayQueue (fd=14, pDisplay=0x81b50c8) at
/home/limux/core/vcl/unx/generic/app/saldisp.cxx:407
#8 0x47daa521 in YieldEntry::IsEventQueued (this=0x47e9b250) at
/home/limux/core/vcl/unx/generic/app/saldata.cxx:593
#9 0x47da9e18 in SalXLib::Yield (this=0x8060c60, bWait=true, bHandleAllCurrentEvents=false) at
/home/limux/core/vcl/unx/generic/app/saldata.cxx:775
#10 0x464cb7dc in KDEXLib::Yield (this=0x8060c58, bWait=true, bHandleAllCurrentEvents=false) at
/home/limux/core/vcl/unx/kde4/KDEXLib.cxx:293
#11 0x47dbd7f5 in X11SalInstance::Yield (this=0x804f780, bWait=true,
bHandleAllCurrentEvents=false) at /home/limux/core/vcl/unx/generic/app/salinst.cxx:164
#12 0x428fe2fa in ImplYield (i_bWait=true, i_bAllEvents=false) at
/home/limux/core/vcl/source/app/svapp.cxx:425
#13 0x428fa8fe in Application::Yield (i_bAllEvents=false) at
/home/limux/core/vcl/source/app/svapp.cxx:459
#14 0x428fa898 in Application::Execute () at /home/limux/core/vcl/source/app/svapp.cxx:404
#15 0x4010d1f7 in desktop::Desktop::Main (this=0xbfff8ab8) at
/home/limux/core/desktop/source/app/app.cxx:1713
#16 0x42905baf in ImplSVMain () at /home/limux/core/vcl/source/app/svmain.cxx:162
#17 0x42905ccd in SVMain () at /home/limux/core/vcl/source/app/svmain.cxx:199
#18 0x4014ef9e in soffice_main () at /home/limux/core/desktop/source/app/sofficemain.cxx:83
#19 0x0804873c in sal_main () at /home/limux/core/desktop/source/app/main.c:48
#20 0x08048713 in main (argc=5, argv=0xbfff8bf4) at /home/limux/core/desktop/source/app/main.c:47
It seems to me that X's global error handler is the primary design
drop-off here; there should be one per display (?). Having said that - I
wonder if there is some nice way we can clobber Java's XError handler
entirely, and/or stop it mis-behaving ?
Fixed thusly, We'll see what the AWT devs say.
Andrew.
--- Begin Message ---
This one was reported by the LibreOffice folks.
We don't check the return argument of JNU_GetEnv() in ToolkitErrorHandler:
static int ToolkitErrorHandler(Display * dpy, XErrorEvent * event) {
if (jvm != NULL) {
JNIEnv * env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
return JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XToolkit", "globalErrorHandler",
"(JJ)I",
ptr_to_jlong(dpy), ptr_to_jlong(event)).i;
} else {
return 0;
}
}
JNU_GetEnv() will return NULL if this thread is not a Java thread, so
we crash. This will happen if SWT is loaded in an application that
uses X itself in some threads.
The patch is pretty trivial, we just have to check env before using it:
--- jdk/src/solaris/native/sun/xawt/XlibWrapper.c~ 2012-10-11 17:20:54.000000000 +0100
+++ jdk/src/solaris/native/sun/xawt/XlibWrapper.c 2012-11-30 10:52:19.980613972 +0000
@@ -1260,13 +1260,15 @@
JavaVM* jvm = NULL;
static int ToolkitErrorHandler(Display * dpy, XErrorEvent * event) {
+ JNIEnv * env;
if (jvm != NULL) {
- JNIEnv * env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- return JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XToolkit", "globalErrorHandler",
"(JJ)I",
- ptr_to_jlong(dpy), ptr_to_jlong(event)).i;
- } else {
- return 0;
+ env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+ if (env) {
+ return JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XToolkit",
"globalErrorHandler", "(JJ)I",
+ ptr_to_jlong(dpy), ptr_to_jlong(event)).i;
+ }
}
+ return 0;
}
/*
Andrew.
--- End Message ---
Context
- Re: Java/SWING + VCL / X crasher ... (continued)
Re: Java/SWING + VCL / X crasher ... · Andrew Haley
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.