After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 321553 - Having a swing component instance in a JG application which uses org.gnu.glib.CustomEvents crashes the (sun) jvm
Having a swing component instance in a JG application which uses org.gnu.glib...
Status: VERIFIED FIXED
Product: java-gnome
Classification: Bindings
Component: GTK
mainline
Other All
: High critical
: ---
Assigned To: java-gnome bindings maintainers
java-gnome bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2005-11-15 22:48 UTC by Bodo-Merle Sandor
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: 2.11/2.12


Attachments
rename JNU_GetEnv to JG_JNU_GetEnv. (1.22 KB, patch)
2005-11-16 20:11 UTC, Bodo-Merle Sandor
committed Details | Review
rename JNU_GetEnv to JG_JNU_GetEnv. (1.21 KB, patch)
2005-11-16 20:12 UTC, Bodo-Merle Sandor
committed Details | Review

Description Bodo-Merle Sandor 2005-11-15 22:48:44 UTC
Steps to reproduce:
By uncommenting the line containing JPanel - the jvm will crash.
Java VM: Java HotSpot(TM) Client VM (1.5.0_04-b05 mixed mode, sharing)

import javax.swing.JPanel;

import org.gnu.glib.CustomEvents;
import org.gnu.gtk.Gtk;
import org.gnu.gtk.Window;

public class CustomEventTest {

	public static void main(String[] args) {
		//JPanel panel = new JPanel();
	
		Thread t = new Thread(new Runnable() {
			public void run() {
				Gtk.init(null);
				Gtk.main();
			}
		});
		t.start();
		
		CustomEvents.addEvent(new Runnable() {
			public void run() {
				Window w = new Window();
				w.showAll();
			}
		});
	}
}

Stack trace:
Stack: [0xb1a32000,0xb1ab2000),  sp=0xb1ab0b70,  free space=506k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libjava.so+0x118ac]  JNU_GetEnv+0x1c
C  [libgtkjni-2.8.so+0x80086]  function+0x16
C  [libgtkjni-2.8.so+0x8011d]  dispatch+0xd
C  [libglib-2.0.so.0+0x23a61]  g_main_context_dispatch+0x211
C  [libglib-2.0.so.0+0x26cb7]
C  [libglib-2.0.so.0+0x27208]  g_main_loop_run+0x1a8
C  [libgtk-x11-2.0.so.0+0x12d019]  gtk_main+0xb9
C  [libgtkjni-2.8.so+0x8f996]  Java_org_gnu_gtk_Gtk_gtk_1main+0x16
j  org.gnu.gtk.Gtk.gtk_main()V+0
j  org.gnu.gtk.Gtk.main()V+6
j  CustomEventTest$1.run()V+4
j  java.lang.Thread.run()V+11
v  ~StubRoutines::call_stub
V  [libjvm.so+0x16bf8c]
V  [libjvm.so+0x25e5f8]
V  [libjvm.so+0x16b7e5]
V  [libjvm.so+0x16b87e]
V  [libjvm.so+0x1d0fd5]
V  [libjvm.so+0x2b76d3]
V  [libjvm.so+0x25f108]
C  [libpthread.so.0+0x51ee]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  org.gnu.gtk.Gtk.gtk_main()V+0
j  org.gnu.gtk.Gtk.main()V+6
j  CustomEventTest$1.run()V+4
j  java.lang.Thread.run()V+11
v  ~StubRoutines::call_stub


Other information:
The crash happens in JNU_GetEnv. Most probably cached_jvm is null when we have a
swing component - but this need to be checked.

Note - the above code works fine with gij:

java version "1.4.2"
gij (GNU libgcj) version 4.0.3 20051023 (prerelease) (Ubuntu 4.0.2-3ubuntu1)
Comment 1 Bodo-Merle Sandor 2005-11-16 20:10:04 UTC
The problem lied in the fact that both the sun jvm and both jg-common provided
JNU_GetEnv with different implementation. Sun jvm ended up calling its own
JNU_GetEnv when it should have been call the jg-common version.
Fixed by renaming JNU_GetEnv to JG_JNU_GetEnv.
Comment 2 Bodo-Merle Sandor 2005-11-16 20:11:30 UTC
Created attachment 54838 [details] [review]
rename JNU_GetEnv to JG_JNU_GetEnv.

patch against jg-common.
Comment 3 Bodo-Merle Sandor 2005-11-16 20:12:19 UTC
Created attachment 54839 [details] [review]
rename JNU_GetEnv to JG_JNU_GetEnv.

patch against libgtk-java.
Comment 4 Ismael Juma 2005-11-26 13:52:56 UTC
Thanks for the patch. Applied to CVS HEAD.