commit:     23e8fa2dfbb91d9e3da98e3da7c607085df62406
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 10 22:22:05 2015 +0000
Commit:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
CommitDate: Sat Oct 10 22:22:53 2015 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=23e8fa2d

dev-java/icedtea: Backport XShm fix from 2.7.0

Addresses bug #561500.

Package-Manager: portage-2.2.20.1

 dev-java/icedtea/files/TryXShmAttach.patch         | 201 +++++++++++++++++++++
 ...ea-7.2.6.1.ebuild => icedtea-7.2.6.1-r1.ebuild} |   4 +
 2 files changed, 205 insertions(+)

diff --git a/dev-java/icedtea/files/TryXShmAttach.patch 
b/dev-java/icedtea/files/TryXShmAttach.patch
new file mode 100644
index 0000000..4157bb6
--- /dev/null
+++ b/dev-java/icedtea/files/TryXShmAttach.patch
@@ -0,0 +1,201 @@
+
+# HG changeset patch
+# User andrew
+# Date 1438275152 -3600
+# Node ID a2334007f1a8504d2bd4a2c2a037732c289649c3
+# Parent  ab23850139cb2c666e613010842a1f984b184a3a
+PR2568: openjdk causes a full desktop crash on RHEL 6 i586
+Summary: Re-apply "8025775: JNI warnings in TryXShmAttach"; some changes lost 
in bad merge changeset 4b26f93b23ba
+
+diff -r ab23850139cb -r a2334007f1a8 
src/solaris/classes/sun/awt/X11/XConstants.java
+--- openjdk/jdk/src/solaris/classes/sun/awt/X11/XConstants.java        Wed Oct 
23 10:50:34 2013 +0200
++++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XConstants.java        Thu Jul 
30 17:52:32 2015 +0100
+@@ -699,9 +699,4 @@
+     public static final long XkbModifierMapMask = (1L<<2);
+     public static final long XkbVirtualModsMask = (1L<<6); //server map
+ 
+-    /*****************************************************************
+-     * X SHARED MEMORY EXTENSION FUNCTIONS
+-     *****************************************************************/
+-
+-    public static final int X_ShmAttach = 1;
+ }
+diff -r ab23850139cb -r a2334007f1a8 
src/solaris/classes/sun/awt/X11/XErrorHandler.java
+--- openjdk/jdk/src/solaris/classes/sun/awt/X11/XErrorHandler.java     Wed Oct 
23 10:50:34 2013 +0200
++++ openjdk/jdk/src/solaris/classes/sun/awt/X11/XErrorHandler.java     Thu Jul 
30 17:52:32 2015 +0100
+@@ -41,29 +41,6 @@
+             return XErrorHandlerUtil.SAVED_XERROR_HANDLER(display, err);
+         }
+     }
+- 
+-    /**
+-     * This is a base synthetic error handler containing a boolean flag which 
allows
+-     * to show that an error is handled or not.
+-     */
+-    public static class XErrorHandlerWithFlag extends XBaseErrorHandler {
+-        private volatile boolean errorOccurred = false;
+-
+-        public boolean getErrorOccurredFlag() {
+-            return errorOccurred;
+-        }
+-
+-        /**
+-         * Sets an internal boolean flag to a particular value. Should be 
always called
+-         * with {@code false} value of the parameter {@code errorOccurred} 
before this
+-         * error handler is set as current.
+-         * @param errorOccurred {@code true} to indicate that an error was 
handled,
+-         *     {@code false} to reset the internal boolean flag
+-         */
+-        public void setErrorOccurredFlag(boolean errorOccurred) {
+-            this.errorOccurred = errorOccurred;
+-        }
+-    }
+ 
+     /*
+      * Instead of validating window id, we simply call XGetWindowProperty,
+@@ -99,75 +76,4 @@
+             return theInstance;
+         }
+     }
+-
+-    /**
+-     * This is a synthetic error handler for errors generated by the native 
function
+-     * {@code XShmAttach}. If an error is handled, an internal boolean flag 
of the
+-     * handler is set to {@code true}.
+-     */
+-    public static final class XShmAttachHandler extends XErrorHandlerWithFlag 
{
+-        private XShmAttachHandler() {}
+-
+-        @Override
+-        public int handleError(long display, XErrorEvent err) {
+-            if (err.get_minor_code() == XConstants.X_ShmAttach) {
+-                setErrorOccurredFlag(true);
+-                return 0;
+-            }
+-            return super.handleError(display, err);
+-        }
+-
+-        // Shared instance
+-        private static XShmAttachHandler theInstance = new 
XShmAttachHandler();
+-        public static XShmAttachHandler getInstance() {
+-            return theInstance;
+-        }
+-    }
+-
+-    /**
+-     * This is a synthetic error handler for {@code BadAlloc} errors 
generated by the
+-     * native {@code glX*} functions. Its internal boolean flag is set to 
{@code true},
+-     * if an error is handled.
+-     */
+-    public static final class GLXBadAllocHandler extends 
XErrorHandlerWithFlag {
+-        private GLXBadAllocHandler() {}
+-
+-        @Override
+-        public int handleError(long display, XErrorEvent err) {
+-            if (err.get_error_code() == XConstants.BadAlloc) {
+-                setErrorOccurredFlag(true);
+-                return 0;
+-            }
+-            return super.handleError(display, err);
+-        }
+-
+-        private static GLXBadAllocHandler theInstance = new 
GLXBadAllocHandler();
+-        public static GLXBadAllocHandler getInstance() {
+-            return theInstance;
+-        }
+-    }
+-
+-    /**
+-     * This is a synthetic error handler for errors generated by the native 
function
+-     * {@code XChangeWindowAttributes}. If an error is handled, an internal 
boolean
+-     * flag of the handler is set to {@code true}.
+-     */
+-    public static final class XChangeWindowAttributesHandler extends 
XErrorHandlerWithFlag {
+-        private XChangeWindowAttributesHandler() {}
+-
+-        @Override
+-        public int handleError(long display, XErrorEvent err) {
+-            if ((err.get_request_code() == 
XProtocolConstants.X_ChangeWindowAttributes) &&
+-                (err.get_error_code() == XConstants.BadAccess)) {
+-                setErrorOccurredFlag(true);
+-                return 0;
+-            }
+-            return super.handleError(display, err);
+-        }
+-
+-        private static XChangeWindowAttributesHandler theInstance = new 
XChangeWindowAttributesHandler();
+-        public static XChangeWindowAttributesHandler getInstance() {
+-            return theInstance;
+-        }
+-    }
+ }
+diff -r ab23850139cb -r a2334007f1a8 
src/solaris/native/sun/awt/awt_GraphicsEnv.h
+--- openjdk/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.h   Wed Oct 23 
10:50:34 2013 +0200
++++ openjdk/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.h   Thu Jul 30 
17:52:32 2015 +0100
+@@ -54,7 +54,7 @@
+ 
+ void TryInitMITShm(JNIEnv *env, jint *shmExt, jint *shmPixmaps);
+ void resetXShmAttachFailed();
+-jboolean TryXShmAttach(JNIEnv *env, Display *display, XShmSegmentInfo 
*shminfo);
++jboolean isXShmAttachFailed();
+ 
+ #endif /* MITSHM */
+ 
+diff -r ab23850139cb -r a2334007f1a8 
src/solaris/native/sun/awt/awt_xembed_server.c
+--- openjdk/jdk/src/solaris/native/sun/awt/awt_xembed_server.c Wed Oct 23 
10:50:34 2013 +0200
++++ openjdk/jdk/src/solaris/native/sun/awt/awt_xembed_server.c Thu Jul 30 
17:52:32 2015 +0100
+@@ -644,19 +644,12 @@
+     return dim;
+ }
+ 
+-Boolean isMapped(JNIEnv* env, Window w) {
++Boolean isMapped(Window w) {
+     XWindowAttributes attr;
+     Status status = 0;
+-    jboolean errorOccurredFlag;
+-    jobject errorHandlerRef;
+-    jobject savedError;
+-    unsigned char xerror_code;
+-
+-    EXEC_WITH_XERROR_HANDLER(env, 
"sun/awt/X11/XErrorHandler$IgnoreBadWindowHandler",
+-        "()Lsun/awt/X11/XErrorHandler$IgnoreBadWindowHandler;", JNI_FALSE,
+-        errorHandlerRef, errorOccurredFlag,
+-        status = XGetWindowAttributes(awt_display, w, &attr));
+-    xerror_code = GET_XERROR_CODE(env, savedError);
++    WITH_XERROR_HANDLER(xerror_ignore_bad_window);
++    status = XGetWindowAttributes(awt_display, w, &attr);
++    RESTORE_XERROR_HANDLER;
+     if (status == 0 || xerror_code != Success) {
+         return False;
+     }
+@@ -692,7 +685,7 @@
+             sdata->version = *data;
+             flags = *(data+1);
+             new_mapped = (flags & XEMBED_MAPPED) != 0;
+-            currently_mapped = isMapped(env, sdata->handle);
++            currently_mapped = isMapped(sdata->handle);
+             if (new_mapped != currently_mapped) {
+                 if (new_mapped) {
+                     XMapWindow(awt_display, sdata->handle);
+diff -r ab23850139cb -r a2334007f1a8 
src/solaris/native/sun/java2d/x11/X11SurfaceData.c
+--- openjdk/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c     Wed Oct 
23 10:50:34 2013 +0200
++++ openjdk/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c     Thu Jul 
30 17:52:32 2015 +0100
+@@ -551,8 +551,6 @@
+ {
+     XImage *img = NULL;
+     XShmSegmentInfo *shminfo;
+-    JNIEnv* env;
+-    jboolean xShmAttachResult;
+ 
+     shminfo = malloc(sizeof(XShmSegmentInfo));
+     if (shminfo == NULL) {
+@@ -603,7 +601,7 @@
+      */
+     shmctl(shminfo->shmid, IPC_RMID, 0);
+ 
+-    if (xShmAttachResult == JNI_FALSE) {
++    if (isXShmAttachFailed() == JNI_TRUE) {
+         J2dRlsTraceLn1(J2D_TRACE_ERROR,
+                        "X11SD_SetupSharedSegment XShmAttach has failed: %s",
+                        strerror(errno));
+

diff --git a/dev-java/icedtea/icedtea-7.2.6.1.ebuild 
b/dev-java/icedtea/icedtea-7.2.6.1-r1.ebuild
similarity index 98%
rename from dev-java/icedtea/icedtea-7.2.6.1.ebuild
rename to dev-java/icedtea/icedtea-7.2.6.1-r1.ebuild
index 2027cea..9645c54 100644
--- a/dev-java/icedtea/icedtea-7.2.6.1.ebuild
+++ b/dev-java/icedtea/icedtea-7.2.6.1-r1.ebuild
@@ -284,6 +284,10 @@ src_configure() {
 
        unset JAVA_HOME JDK_HOME CLASSPATH JAVAC JAVACFLAGS
 
+       # https://bugs.gentoo.org/show_bug.cgi?id=561500
+       ln -s "${FILESDIR}/TryXShmAttach.patch" || die
+       export DISTRIBUTION_PATCHES="TryXShmAttach.patch"
+
        econf ${config} \
                --with-openjdk-src-zip="${DISTDIR}/${OPENJDK_GENTOO_TARBALL}" \
                --with-corba-src-zip="${DISTDIR}/${CORBA_GENTOO_TARBALL}" \

Reply via email to