Using createInstance to instantiate a XPCOM service breaks Firefox
Categories
(Core :: XPCOM, defect)
Tracking
()
People
(Reporter: whimboo, Unassigned)
References
Details
(Keywords: student-project)
Any code which calls createInstance to instantiate a XPCOM service will break Firefox. Any successive calls to e.g. the pref service (see attachment 379330 [details] as testcase which need chrome perms).
Do the following steps:
1. Save the testcase to your local disk
2. Open and run the testcase
3. Reload the page
To see the errors open the Error Console and try to open the preferences dialog afterward. It will be empty and a lot of errors are reported.
Given by Benjamin I'll add the student-project keyword.
Comment 1•15 years ago
|
||
Note that what I'd like to see is a flag when you register a component indicating whether callers should be using it with .getService or .createInstance, and the component manager would prevent the other. This may involve additions to the registration API.
Comment 5•15 years ago
|
||
This seems to be a common mistake leading to subtle crashes.
Updated•14 years ago
|
Hi I am interested in working on this bug,but it's my first time to work on with debug,can anybody guide me on how to get started with it?Thanks a lot.
Comment 7•3 years ago
|
||
Hey Henrik,
Can you still reproduce this issue or should we close it?
Reporter | ||
Comment 8•3 years ago
|
||
The original test case from comment 0 doesn't work anymore given that enablePrivilege
has been removed in Firefox. But I tried with some similar code in the Browser Toolbox, and I don't get a failure, nor does the call to screenForRect()
fail:
var cls = "@mozilla.org/gfx/screenmanager;1";
var service = Ci.nsIScreenManager;
Components.classes[cls].createInstance(service);
alert(Components.classes[cls].getService(service).screenForRect(0, 0, 1, 1));
Nika, do those lines represent the same underlying issue, or might it have been a problem in combination with enablePrivilege()
, and we can close this bug?
Comment 9•3 years ago
|
||
It may still be possible to trigger bugs by explicitly calling createInstance
for an XPCOM service in various places, but given that we no longer support legacy extensions, I don't think this is a big deal. I think we can resolve this as wontfix for now, and if it comes up as an ongoing issue we can open a new bug.
Description
•