Closed
Bug 366724
Opened 19 years ago
Closed 10 years ago
Crash in "vtable for XPCWrappedNativeScope" if setCommandContext() called with a GCable object
Categories
(Core Graveyard :: Embedding: APIs, defect)
Core Graveyard
Embedding: APIs
Tracking
(Not tracked)
RESOLVED
INCOMPLETE
People
(Reporter: awuest, Assigned: timeless)
Details
(Keywords: crash, testcase)
Attachments
(4 files, 1 obsolete file)
|
3.23 KB,
text/plain
|
Details | |
|
4.52 KB,
patch
|
neil
:
review-
|
Details | Diff | Splinter Review |
|
1.24 KB,
text/plain
|
Details | |
|
4.18 KB,
patch
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1
Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1
If a "@mozilla.org/embedcomp/base-command-controller;1" is initialised with setCommandContext(param) and param != null, then executing IsCommandEnabled() on a registered command crashes in vtable for XPCWrappedNativeScope (see testcase for reproduction and backtrace).
Reproducible: Always
Steps to Reproduce:
1. Instantiate new "@mozilla.org/embedcomp/base-command-controller;1"
2. setCommandContext() with a parameter != null
3. register a command
4. call IsCommandEnabled
Actual Results:
Crash in "vtable for XPCWrappedNativeScope"
Expected Results:
No crash.
This happens with Firefox 2.0.0.1 as well as 1.5.
| Reporter | ||
Comment 1•19 years ago
|
||
| Reporter | ||
Comment 2•19 years ago
|
||
If setCommandContext(null) is called instead of setCommandContext(Container), then it does not crash.
(If somebody knows how to run this code outside of a priviledged chrome URI, please tell me so.)
you could have at least cc'd neil...
http://www.mozilla.org/projects/security/components/signed-scripts.html kinda explains how to do this w/o chrome.
Assignee: nobody → timeless
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #251262 -
Flags: review?(neil)
Comment 4•19 years ago
|
||
Comment on attachment 251262 [details] [diff] [review]
hold pointers properly?
Do any existing consumers expect this to hold a weak pointer without using a weak reference? (Note that you can avoid the crash in existing releases by implementing QueryInterface with nsISupportsWeakReference et. al.)
Updated•19 years ago
|
Assignee: timeless → nobody
Status: ASSIGNED → NEW
Flags: review?(neil)
OS: Mac OS X → All
Product: Firefox → Core
QA Contact: general → general
Hardware: Macintosh → All
Version: unspecified → Trunk
Assignee: nobody → timeless
Component: General → Embedding: APIs
Keywords: crash
QA Contact: general → apis
Attachment #251262 -
Flags: review?(neil)
| Reporter | ||
Comment 5•19 years ago
|
||
(In reply to comment #3)
> Created an attachment (id=251262) [details]
> hold pointers properly?
>
> you could have at least cc'd neil...
Sorry, I forgot that. I've tried to track him down on IRC instead.
> http://www.mozilla.org/projects/security/components/signed-scripts.html kinda
> explains how to do this w/o chrome.
Thanks! :)
Comment 6•19 years ago
|
||
The interface documentation says:
61 * @param aCommandContext the context passed to commands.
62 * Note that this is *not* addreffed by the
63 * controller, and so needs to outlive it,
64 * or be nulled out.
We could modify that to mention the nsWeakPtr thing if we want.
We could also change the API, but then we need to worry about leaks in existing code that uses the interface, no?
i don't like the idea of changing the interface.
is it possible for us to QI to determine if the object is a GC able object?
I'm pretty sure i can do that for js, i'm not sure how to do it for java.
Comment 8•19 years ago
|
||
Comment on attachment 251262 [details] [diff] [review]
hold pointers properly?
r- as this change of contract has not been justified.
Attachment #251262 -
Flags: review?(neil) → review-
Summary: Crash in "vtable for XPCWrappedNativeScope" if setCommandContext() used with param not null → Crash in "vtable for XPCWrappedNativeScope" if setCommandContext() called with a GCable object
this can be run using xpcshell and has no fluff.
Attachment #251214 -
Attachment is obsolete: true
| Assignee | ||
Comment 10•19 years ago
|
||
reporter: can you test this? :)
I haven't tested the Java and Python code, and I'd like to move the new files and header into xpcom/ since it should be something that xpcom provides somehow.
Design: each known annoying case (currently to my knowledge these are not registered with xpcom, which is sorta unfortunate) is given a fake interface file which enables me to use standard do_QI magic (cleaner from my perspective).
If any of these annoying cases decide to multiply, then each new case would currently become a new file (with a new number, 2, 3 ...) and would be added as another 2 lines in the function.
Callers simply pass the object they don't trust to the function and are given NS_OK if it's safe to use or an error they can return to their callers when the object is unsafe.
A more scalable version of this would be a service which has two methods:
void registerGCableInterface(nsIID);
void isGCableObject(nsISupports);
where javascript, java, python, and friends would be expected to call the service and register their flavors.
Attachment #252470 -
Flags: superreview?(neil)
Attachment #252470 -
Flags: review?(awuest)
Attachment #252470 -
Flags: review?(jhpedemonte)
Attachment #252470 -
Flags: review?(mhammond)
Comment 11•19 years ago
|
||
Better still, demand that all scriptable objects support a given interface?
| Assignee | ||
Comment 12•19 years ago
|
||
that'd sure make our life easier....
Comment 13•19 years ago
|
||
Can we get the best of both worlds by using the cycle collector?
| Assignee | ||
Comment 14•19 years ago
|
||
i don't know anything about the cycle collector....
Flags: in-testsuite?
Comment 15•14 years ago
|
||
Comment on attachment 252470 [details] [diff] [review]
compare against known gcable objects
Almost certainly out of date and I'm no longer up on the code this patch touches.
Attachment #252470 -
Flags: review?(mhammond)
| Reporter | ||
Comment 16•12 years ago
|
||
Comment on attachment 252470 [details] [diff] [review]
compare against known gcable objects
Review of attachment 252470 [details] [diff] [review]:
-----------------------------------------------------------------
Is this approach still current?
Comment 17•10 years ago
|
||
Marking a bunch of bugs in the "Embedding: APIs" component INCOMPLETE in preparation to archive that component. If I have done this incorrectly, please reopen the bugs and move them to a more correct component as we don't have "embedding" APIs any more.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → INCOMPLETE
Updated•7 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•