Closed Bug 99033 Opened 23 years ago Closed 23 years ago

Cannot init gtk from XPCSHELL

Categories

(Core :: XPConnect, defect)

x86
Linux
defect
Not set
normal

Tracking

()

VERIFIED DUPLICATE of bug 98952

People

(Reporter: dolivari, Assigned: shaver)

Details

(Keywords: crash)

Attachments

(1 file)

From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.3) Gecko/20010801
BuildID:    2001080104

As I tried to rewrite the nsAppRunner process in Java Script, I have been
confronted to the fact that nsICmdLineService can't be used from xpcshell
because there is no scriptable method to initialized it.

So you can't call nsIAppShellService::Initialize(in nsICmdLineService
aCmdLineService, in nsISupports nativeAppSupportOrSplashScreen) because your
nsICmdLineService object is invalid.

Initialize try to extract argv and argc to pass them to gtk_init and what I saw
is that gtk_init doesn't like it (Segmentation Fault).

Reproducible: Always
Steps to Reproduce:
Here's the code run under xpcshell :

var EventQClass =
Components.classes['@mozilla.org/event-queue-service;1'];

var EventQObj    = 
EventQClass.getService(Components.interfaces.nsIEventQueueService);

EventQObj.createThreadEventQueue();

var AppShellClass = Components.classes['@mozilla.org/appshell/appShellService;1'];
var AppShellObj =
AppShellClass.getService(Components.interfaces.nsIAppShellService);

var URLClass =  Components.classes['@mozilla.org/network/standard-url;1'];
var URLObj = URLClass.createInstance(Components.interfaces.nsIURL);

URLObj.scheme="file";
URLObj.path="/tmp/test.xul";

AppShellObj.Initialize(null,null);


var test = new Object();
toto = AppShellObj.CreateTopLevelWindow(null,URLObj,
    true,true,
    Components.interfaces.nsIWebBrowserChrome.CHROME_ALL,
    640,480,test);

AppShellObj.Run(); 


Actual Results:  If you try this code you'll get a segmentation fault from gtk.
In http://lxr.mozilla.org/mozilla/source/widget/src/gtk/nsAppShell.cpp#245

Expected Results:  I modified the code of
http://lxr.mozilla.org/mozilla/source/widget/src/gtk/nsAppShell.cpp#245

//gtk_init(&argc,&argv);
char ** t_argv = new char*;
t_argv[0] ="$MOZILLA/dist/bin/xpcshell";
int t_argc=1;
gtk_init (&t_argc,&t_argv);

And then a xul openned.
Attached file Sample XUL File
dolivari@eprocess.fr: is the sample XUL file you have attached
supposed to show the segmentation fault? When I load it and run it,
I do not crash on WinNT or Linux. Using Mozilla binaries 20010909xx.
Status: UNCONFIRMED → NEW
Ever confirmed: true
cc'ing dbradley, jband -
Keywords: crash
Could you not create your own XPCOM object that created, initialized, and
returned an instance of nsICmdLineService. This XPCOM object would have to
figure out the arguments using the appropriate system calls, or just pretend
there aren't any, much like your change does.

> Could you not create your own XPCOM object that created, initialized, and
> returned an instance of nsICmdLineService. This XPCOM object would have to
> figure out the arguments using the appropriate system calls, or just pretend
> there aren't any, much like your change does.

That's what I planned to do but... Mike Shaver ask me to post a bug about this
after my post in netscape.public.mozilla.xpcom.

Phil Schwartau : the xul file attached is just a xul companion for the "bug".

*** This bug has been marked as a duplicate of 98952 ***
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → DUPLICATE
Marking Verified Duplicate -
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: