Fatal error when mixing SWT and Swing on Solaris Sparc [message #900938] |
Thu, 09 August 2012 03:25  |
Eclipse User |
|
|
|
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 #902211 is a reply to message #900938] |
Thu, 16 August 2012 07:50  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03814 seconds