General:
I always receive SIGSEGV on Linux when invoke the XRE_InitEmbedding2 function with XULRunner 15.
Details:
I'm trying to embed Mozilla (XULRunner 15.05b 64-bit) browser component into my GTK application on Fedora 12 64-bit. I created Eclipse project, configured it to use all required XULRunner libraries and include files and successfully built it.
Here's the application code:
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include "nsXPCOM.h"
#include "nsXPCOMGlue.h"
#include "nsEmbedString.h"
#include "nsXULAppAPI.h"
#include "nsILocalFile.h"
using namespace std;
XRE_InitEmbedding2Type XRE_InitEmbedding2Delegate;
int main(int argc, char** argv) {
nsDynamicFunctionLoad kXRESymbols[] = {
{"XRE_InitEmbedding2", (NSFuncPtr*) &XRE_InitEmbedding2Delegate},
{0, 0}
};
GtkWidget *window;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_show(window);
nsresult rv = XPCOMGlueStartup("/home/Victor/Projects/JavaXPCOM/xulrunner-sdk/bin/libxpcom.so");
if (NS_FAILED(rv)) {
return rv;
}
rv = XPCOMGlueLoadXULFunctions(kXRESymbols);
if (NS_FAILED(rv)) {
return rv;
}
nsILocalFile *libXULDir;
rv = NS_NewNativeLocalFile(nsEmbedCString("/home/Victor/Projects/JavaXPCOM/xulrunner-sdk/bin"), PR_FALSE, &libXULDir);
if (NS_FAILED(rv)) {
return rv;
}
rv = XRE_InitEmbedding2Delegate(libXULDir, libXULDir, nsnull);
if (NS_FAILED(rv)) {
return rv;
}
cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
return 0;
}
I compiled this application with the following command line:
make all
Building file: ../src/JavaXPCOMTest.cpp
Invoking: GCC C++ Compiler
g++ -DXPCOM_GLUE_USE_NSPR=1 -DXPCOM_GLUE=1 -I/home/Victor/Projects/JavaXPCOM/xulrunner-sdk/include -I/usr/include/gtk-2.0 -I/usr/include/glib-2.0 -O0 -g3 -Wall -c -fmessage-length=0 -std=gnu++0x `pkg-config --cflags --libs gtk+-2.0` -MMD -MP -MF"src/JavaXPCOMTest.d" -MT"src/JavaXPCOMTest.d" -o"src/JavaXPCOMTest.o" "../src/JavaXPCOMTest.cpp"
Finished building: ../src/JavaXPCOMTest.cpp
Building target: JavaXPCOMTest
Invoking: GCC C++ Linker
g++ -L/home/Victor/Projects/JavaXPCOM/xulrunner-sdk/lib -L/home/Victor/Projects/JavaXPCOM/xulrunner-sdk/bin -Wl,-rpath-link,/home/Victor/Projects/JavaXPCOM/xulrunner-sdk/bin -o"JavaXPCOMTest" ./src/JavaXPCOMTest.o -lxpcomglue -lstdc++ `pkg-config --cflags --libs gtk+-2.0`
Finished building target: JavaXPCOMTest
When I run this application I receive SIGSEGV when invoke the XRE_InitEmbedding2Delegate function with the following call stack:
Thread [1] 15449 (Suspended : Signal)
_dl_fixup() at 0x3dbd60dbec
_dl_runtime_resolve() at 0x3dbd614315
0x7fffee4031d3
0x7fffee429209
0x7fffee429223
0x7fffee42a943
0x7fffee42b7ae
0x7fffee42bb25
NS_InitXPCOM2_P() at 0x7fffee4063a9
XRE_InitEmbedding2() at 0x7fffed998ce7
<...more frames...>
Does anybody reproduced similar issue on Linux platform with XULRunner 15? Maybe I use some wrong command line parameters or forget to include something in command line.