Consider adding a non-leaking (fallible) variant of `nsIEventTarget::Dispatch`
Categories
(Core :: XPCOM, enhancement)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox144 | --- | fixed |
People
(Reporter: nika, Assigned: nika)
References
Details
Attachments
(1 external file)
Dispatches to event targets are currently quite inconsistent. Some event targets (like nsThread) will leak if the dispatch fails, making them effectively infallible, while others (like TaskQueue) will not leak the runnable if the dispatch fails, meaning that dispatched runnables may be released on the wrong thread.
We should consider adding a new variant of Dispatch to nsIEventTarget which is explicitly fallible, and doesn't take ownership from the caller over the runnable unless it successfully dispatches. This could be combined with migrating all existing Dispatch calls to consistently leak on failure, making it possible for callers to make the correct decisions for their use cases.
Alternatively, if changing the existing Dispatch method to be consistent is too difficult (e.g. because of there being code depending on the existing behaviour), it may also be possible to add two explicit variants with leaking and non-leaking, and slowly migrate away from the existing Dispatch call, however due to the number of consumers of the existing API this feels somewhat unappealing.
| Assignee | ||
Comment 1•1 year ago
|
||
Updated•1 year ago
|
Comment 2•1 year ago
|
||
See also bug 1184729 -- Convert Dispatch/DispatchToMainThread/PutEvent uses to already_AddRefed<> -- a different approach than being taken here.
I was working on this as a side project 10+ years ago, but never landed the stack
Comment 5•1 year ago
•
|
||
Backed out for causing leaks complaining about MediaTransportHandlerSTS.
Backout link: https://hg-edge.mozilla.org/integration/autoland/rev/804dd3f494f92892bccd222b3d6a38b58fe8fbcd
Failure logs:
https://treeherder.mozilla.org/logviewer?job_id=524097476&repo=autoland&task=T7BJwoEfTAKyEzSTmkTXFg.0&lineNumber=7625
https://treeherder.mozilla.org/logviewer?job_id=524096198&repo=autoland&task=O1-zfzzcT2qDGMh6F1VBdA.0&lineNumber=1432
| Assignee | ||
Comment 6•1 year ago
|
||
(In reply to Atila Butkovits from comment #5)
Failure logs:
https://treeherder.mozilla.org/logviewer?job_id=524097476&repo=autoland&task=T7BJwoEfTAKyEzSTmkTXFg.0&lineNumber=7625
https://treeherder.mozilla.org/logviewer?job_id=524096198&repo=autoland&task=O1-zfzzcT2qDGMh6F1VBdA.0&lineNumber=1432
The first failure log appears to be a leak when dispatching to the nsSocketTransportService thread. In my patch I made it more consistent so it always leaks on failure when dispatching, whereas previously it would only sometimes leak on failure (when the nsThread::DIspatch fails). That's easy enough to change to never fail given that it seems we were depending on that.
THe second failure is much more confusing, and I don't see how it could be related to this patch. It appears the test is attempting to make a non-local network connection while running, which is leading to a crash as we don't allow nonlocal network connections while running tests. I don't think there's any way that leaking or not leaking a runnable should lead to that crash happening?
Comment 8•1 year ago
|
||
| bugherder | ||
Description
•