Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Fatal error when mixing SWT and Swing on Solaris Sparc(SWT application creashes first time Swing is used on Solaris Sparc.)
Fatal error when mixing SWT and Swing on Solaris Sparc [message #900938] Thu, 09 August 2012 03:25 Go to next message
Milan Vahala is currently offline Milan Vahala
Messages: 7
Registered: October 2011
Junior Member
Hi,
I get a fatal error crash in SWT application when first time I use Swing.
I get this problem only on Solaris Sparc machine. On other architectures it works fine.

Source code to reproduce the problem:

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.*;

public class HelloSwtSwing {

public static void main (String [] args) {
	Display display = new Display ();
	Shell shell = new Shell(display);
	shell.setLayout(new RowLayout());
	
	Button button = new Button(shell, SWT.PUSH);
	button.setText("Swing code");
	button.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			showSwingWindow();
		}
	});
	
	shell.open();
	while (!shell.isDisposed ()) {
		if (!display.readAndDispatch ()) display.sleep ();
	}
	display.dispose ();
}

private static void showSwingWindow() {
	SwingUtilities.invokeLater(new Runnable() {
	       public void run() {
	    	   //Create and set up the window.
	    	   JFrame frame = new JFrame();
	    	   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

	    	   //Add the ubiquitous "Hello World" label.
	    	   JLabel label = new JLabel("Hello World");
	    	   frame.getContentPane().add(label);

	    	   //Display the window.
	    	   frame.pack();
	    	   frame.setVisible(true);
	       }
	});
}

}


I get crash with following error message:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0xb6d32600, pid=25326, tid=2
#
# JRE version: 6.0_27-b07
# Java VM: Java HotSpot(TM) Server VM (20.2-b06 mixed mode solaris-sparc )
# Problematic frame:
# C [libXrender.so.1+0x2600] XRenderFindVisualFormat+0x44

More details are in hs_err_pid12029.log file attached.

I use Java 1.6.0_27-b07 and SWT 3.6.2.
Solaris version is SunOS 5.10 Generic_120011-14 sun4v sparc SUNW,Sun-Fire-T200

I also get the same crash from different source code.
It happens in the first appearance of Swing code in SWT application.
Re: Fatal error when mixing SWT and Swing on Solaris Sparc [message #901014 is a reply to message #900938] Thu, 09 August 2012 08:01 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de Alwis
Messages: 242
Registered: July 2009
Senior Member
Have you ensured you're using XToolkit?

http://www.eclipse.org/swt/faq.php#swtawtsolaris
Re: Fatal error when mixing SWT and Swing on Solaris Sparc [message #901160 is a reply to message #901014] Fri, 10 August 2012 03:40 Go to previous messageGo to next message
Milan Vahala is currently offline Milan Vahala
Messages: 7
Registered: October 2011
Junior Member
Yes, I'm using XToolkit.
There is a callstack in hs_err_pid12029.log containing sun.awt.X11.XToolkit.<clinit>().
I also get the same crash using MToolkit. It seems the problem is somewhere else.
Re: Fatal error when mixing SWT and Swing on Solaris Sparc [message #901704 is a reply to message #900938] Tue, 14 August 2012 04:58 Go to previous messageGo to next message
Milan Vahala is currently offline Milan Vahala
Messages: 7
Registered: October 2011
Junior Member
This crash happens when using GTK version of SWT (swt-3.6.2-gtk-solaris-sparc)
and doesn't happen when using Motif SWT (swt-3.6.2-motif-solaris-sparc).

Re: Fatal error when mixing SWT and Swing on Solaris Sparc [message #902211 is a reply to message #900938] Thu, 16 August 2012 07:50 Go to previous message
Milan Vahala is currently offline Milan Vahala
Messages: 7
Registered: October 2011
Junior Member
Solved.
This problem can occur on all Solaris systems, not just on Solaris Sparc.
The reason why the crash happen is there are two different Xrender libraries on the system.
One is in located in /usr/sfw/lib/libXrender.so.1 and another in /usr/lib/libXrender.so.1.
Theese libraries are different files, so one is not symbolic link to other.
SWT seems to be using /usr/sfw/lib/libXrender.so.1 and SWING is trying to use /usr/lib/libXrender.so.1, so the libraries somehow collides which results in crash.

My solution was to remove(actually rename) the /usr/lib/libXrender.so.1 and replace it with symbolic link to /usr/sfw/lib/libXrender.so.1. This can be done running following commands as root:

mv /usr/lib/libXrender.so.1 /usr/lib/libXrender.so.1.renamed
ln -s /usr/sfw/lib/libXrender.so.1 /usr/lib/libXrender.so.1
Previous Topic:Option in javadoc to rename interfaces/classes
Next Topic:runtime SWT Event Listener Detector
Goto Forum:
  


Current Time: Sat Apr 19 02:52:40 EDT 2014

Powered by FUDForum. Page generated in 0.01723 seconds