eclipse/ebz569853-1.patch
DistroBaker ca1c7600c0 Merged update from upstream sources
This is an automated DistroBaker update from upstream sources.
If you do not know what this is about or would like to opt out,
contact the OSCI team.

Source: https://src.fedoraproject.org/rpms/eclipse.git#b4c147d96ef29ffc330e7c5fbe9e9f8e84a24ce9
2021-02-06 18:02:56 +00:00

116 lines
3.9 KiB
Diff

From 2684843e3d22bb177a6c6b21c3ee75f3bb3d250e Mon Sep 17 00:00:00 2001
From: Simeon Andreev
Date: Mon, 21 Dec 2020 12:52:01 +0100
Subject: Bug 569853 - jstack crashes Eclipse when running on Java 11
1) Always call DetachCurrentThread if AttachCurrentThreadAsDaemon was
called before, see
https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/invocation.html#detaching_from_the_vm.
2) Specify JNI 1.4 version in JNI_OnLoad, see
https://docs.oracle.com/en/java/javase/11/docs/specs/jni/invocation.html#jni_onload
3) Added printf around attach/detach for easier debugging.
4) Fixed build.sh to allow c99 standard for the for loop defined in
DEBUG_CALL_PRINTS and resolve compilation error below if
DEBUG_CALL_PRINTS is enabled:
callback.c:1252:3: error: 'for' loop initial declarations are only
allowed in C99 mode
Main change is 1), it is a workaround for jstack / JVM bug described in
https://bugzilla.redhat.com/show_bug.cgi?id=1897150
Change-Id: I3ba32d9bef217e5ffc76b8802e7e59de503a2161
---
.../Eclipse SWT/common/library/callback.c | 28 +++++++++-------------
.../Eclipse SWT/common/library/swt.c | 6 +----
.../Eclipse SWT/common/library/swt.h | 1 -
4 files changed, 13 insertions(+), 24 deletions(-)
diff --git a/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c b/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c
index 1e37e28810..0bd7b87a77 100644
--- a/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c
+++ b/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c
@@ -1298,24 +1298,15 @@ jlong callback(int index, ...)
}
#endif
-#ifdef JNI_VERSION_1_2
- if (IS_JNI_1_2) {
- (*JVM)->GetEnv(JVM, (void **)&env, JNI_VERSION_1_2);
- }
-#endif
-
-#ifdef JNI_VERSION_1_4
- if (env == NULL) {
- if (JNI_VERSION >= JNI_VERSION_1_4) {
- (*JVM)->AttachCurrentThreadAsDaemon(JVM, (void **)&env, NULL);
- }
- }
+(*JVM)->GetEnv(JVM, (void **)&env, JNI_VERSION_1_4);
+
+if (env == NULL) {
+ (*JVM)->AttachCurrentThreadAsDaemon(JVM, (void **)&env, NULL);
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SWT-JNI: AttachCurrentThreadAsDaemon\n");
#endif
-
- if (env == NULL) {
- (*JVM)->AttachCurrentThread(JVM, (void **)&env, NULL);
- if (IS_JNI_1_2) detach = 1;
- }
+ detach = 1;
+}
/* If the current thread is not attached to the VM, it is not possible to call into the VM */
if (env == NULL) {
@@ -1391,6 +1382,9 @@ done:
if (detach) {
(*JVM)->DetachCurrentThread(JVM);
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SWT-JNI: DetachCurrentThread\n");
+#endif
env = NULL;
}
diff --git a/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/common/library/swt.c b/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/common/library/swt.c
index e78a2e4811..483aae2d47 100644
--- a/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/common/library/swt.c
+++ b/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/common/library/swt.c
@@ -14,16 +14,12 @@
#include "swt.h"
-int IS_JNI_1_2 = 0;
JavaVM *JVM = NULL;
-#ifdef JNI_VERSION_1_2
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
- IS_JNI_1_2 = 1;
JVM = vm;
- return JNI_VERSION_1_2;
+ return JNI_VERSION_1_4;
}
-#endif
void throwOutOfMemory(JNIEnv *env) {
jclass clazz = (*env)->FindClass(env, "java/lang/OutOfMemoryError");
diff --git a/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/common/library/swt.h b/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/common/library/swt.h
index fa228e9971..32f39f01bd 100644
--- a/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/common/library/swt.h
+++ b/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT/common/library/swt.h
@@ -29,7 +29,6 @@
extern "C" {
#endif
-extern int IS_JNI_1_2;
extern JavaVM *JVM;
/* #define DEBUG */
--
cgit v1.2.1