Closed Bug 494946 Opened 15 years ago Closed 3 years ago

Using createInstance to instantiate a XPCOM service breaks Firefox

Categories

(Core :: XPCOM, defect)

defect
Not set
major

Tracking

()

RESOLVED WONTFIX

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.
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.
No longer blocks: 494186
This seems to be a common mistake leading to subtle crashes.
Blocks: 325395
Assignee: nobody → andregranovsky
Status: NEW → ASSIGNED
Assignee: andregranovsky → nobody
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.

Hey Henrik,
Can you still reproduce this issue or should we close it?

Flags: needinfo?(hskupin)

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?

Flags: needinfo?(hskupin) → needinfo?(nika)

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.

Status: NEW → RESOLVED
Closed: 3 years ago
Flags: needinfo?(nika)
Resolution: --- → WONTFIX
See Also: → 1749032
You need to log in before you can comment on or make changes to this bug.