Closed
Bug 302227
Opened 20 years ago
Closed 4 years ago
Modal dialog run from onStateChange(STATE_START) may crash
Categories
(Core :: Networking, defect, P5)
Core
Networking
Tracking
()
RESOLVED
INCOMPLETE
mozilla1.9alpha1
People
(Reporter: darin.moz, Unassigned)
References
Details
(Whiteboard: [necko-would-take])
Attachments
(1 file)
|
5.40 KB,
patch
|
Details | Diff | Splinter Review |
Modal dialog run from onStateChange(STATE_START) may crash.
The problem occurs because of code like this in AsyncOpen implementations:
NS_IMETHODIMP nsFooChannel::AsyncOpen(... listener) {
...
mStreamPump->AsyncRead(this);
...
mLoadGroup->AddRequest(this);
mListener = listener;
return NS_OK;
}
NS_IMETHODIMP nsFooChannel::OnStartRequest(...) {
return mListener->OnStartRequest(...);
}
The AddRequest call on the LoadGroup object causes onStateChange(STATE_START) to
be sent to WebProgressListener implementations. If any WPL calls window.alert,
then it will cause ProcessPendingEvents to be run, which may cause events from
nsFooChannel's mStreamPump to run before AddRequest returns. This may cause
nsFooChannel's OnStartRequest method to run, which would crash because mListener
is not yet initialized.
This is definitely a problem with nsFileChannel, and it is likely a problem with
other channels as well. I for one do not like APIs like this that result in
channel code being re-entered before AsyncOpen returns because that makes
implementing AsyncOpen very tricky. Remember: AsyncOpen needs to only store
mListener if it is going to return NS_OK because setting mListener may result in
a reference cycle that will only be broken with OnStopRequest runs. So, solving
this bug is tricky. I really wish that onStateChange(STATE_START) were an
asynchronous event instead, but I'm not sure if we can make such a change.
Comment 1•20 years ago
|
||
We could document that modal dialogs are not allowed from onStateChange... We
already have such restrictions on other apis (eg nsIContentPolicy).
| Reporter | ||
Comment 2•20 years ago
|
||
*** Bug 304259 has been marked as a duplicate of this bug. ***
it won't work, see duplicate.
document that objects should not call out to arbitrary xpcom code in an
inconsistent state. and after documenting it, fix mozilla to honor the doc :)
i think i can find some people to work on that.
| Reporter | ||
Updated•20 years ago
|
Target Milestone: --- → mozilla1.8beta4
| Reporter | ||
Comment 4•20 years ago
|
||
My plan is two-fold:
1) Re-arrange assignment of mListener so that if we do execute OnStartRequest
before AddRequest returns, we at least won't crash in Necko.
2) Document that modal dialogs cannot be shown in onStateChange(STATE_START).
I'm not sure about other states.
Long-term we should fix event queues to not process the events of an elder queue
when popped.
| Reporter | ||
Comment 5•20 years ago
|
||
> 2) Document that modal dialogs cannot be shown in onStateChange(STATE_START).
> I'm not sure about other states.
i'll repeat. you can't do this. venkman will push a nested event queue to debug
js called in onStateChange
| Reporter | ||
Comment 7•20 years ago
|
||
> i'll repeat. you can't do this. venkman will push a nested event queue to debug
> js called in onStateChange
OK. that's good to know. sorry, i don't recall where you had mentioned venkman
before. i think we will not solve this bug completely for gecko 1.8. for gecko
1.9, my plan is still to make it so that nested event queues do not process
events targeted at a parent event queue when they are popped.
comment 3 "it won't work, see duplicate" Bug 304259 comment 0
| Reporter | ||
Comment 9•20 years ago
|
||
(In reply to comment #8)
> comment 3 "it won't work, see duplicate" Bug 304259 comment 0
there are no references to venkman (that i can see) in that bug either, but ok.
Comment 11•20 years ago
|
||
Bug 304259 comment 0 jsd3250.dll!jsdService::EnterNestedEventLoop
bug 254151 comment 7
Comment 12•20 years ago
|
||
this is needed for the 1.8 branch, not having it means that using venkman with
any code that interacts with channels is likely to result in crashes.
Flags: blocking1.8b5?
| Reporter | ||
Comment 13•20 years ago
|
||
Even with this patch (or the complete one), you're still likely to run into
trouble using venkman that way. The problem is that this will still setup odd
re-entrancy conditions on consumes of Necko. So, even if Necko is okay with the
odd re-entrancy, it's consumers may not. And, due to the fact that events in
elder queues are processed when popping a younger queue, there is no good way
for Necko to prevent said re-entrancy from occuring. The best solution is to
fix PopThreadEventQueue to not ProcessPendingEvents on all queues, but that is
likely to have other implications, which would be way too risky to entertain on
the 1.8 branch.
Comment 14•20 years ago
|
||
having something would be better than what we have now, and if we hit other
things, we'll report them.
Updated•20 years ago
|
Flags: blocking1.8b5? → blocking1.8b5-
| Reporter | ||
Updated•20 years ago
|
Target Milestone: mozilla1.8beta4 → mozilla1.8beta5
| Reporter | ||
Updated•20 years ago
|
Flags: blocking1.8rc1?
Comment 15•20 years ago
|
||
not gonna make the 1.5 train. maybe in a dot release if we come up with a
low-risk fix that actually solves the venkman problems.
Flags: blocking1.8rc1? → blocking1.8rc1-
| Reporter | ||
Updated•20 years ago
|
Target Milestone: mozilla1.8beta5 → mozilla1.9alpha
Comment 16•20 years ago
|
||
this is still a big problem especially when we need to find out why progress meters don't end up at done.
| Reporter | ||
Updated•20 years ago
|
Depends on: basechannel
| Reporter | ||
Updated•20 years ago
|
Priority: -- → P2
| Reporter | ||
Comment 17•19 years ago
|
||
-> defaults
Assignee: darin.moz → nobody
QA Contact: benc → networking
Updated•19 years ago
|
Flags: blocking1.9?
Comment 18•19 years ago
|
||
Not going to block on this, but we'd love a patch.
Flags: blocking1.9? → blocking1.9-
Comment 19•19 years ago
|
||
Benjamin, I thought we wanted to at least block on API documentation that says that extensions shouldn't do this?
Comment 20•19 years ago
|
||
I wouldn't consider this a stop-ship, no.
Comment 21•19 years ago
|
||
Sure, but I still think the docs are wanted.
Updated•16 years ago
|
Severity: major → critical
Comment 22•8 years ago
|
||
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Priority: P2 → P5
Comment 23•4 years ago
|
||
Marking this as Resolved > Incomplete since the reporter's email has been deactivated and there's no way of asking for a repro.
If anyone can still reproduce this issue please re-open this issue or file a new one.
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → INCOMPLETE
You need to log in
before you can comment on or make changes to this bug.
Description
•