Consider actively blocking accidental attempts to dispatch to the thread queue of threadpool threads
Categories
(Core :: XPCOM, enhancement)
Tracking
()
Tracking | Status | |
---|---|---|
firefox110 | --- | fixed |
People
(Reporter: nika, Assigned: nika)
References
Details
Attachments
(2 files)
Currently it's possible to dispatch to the backing thread of a threadpool accidentally when querying the current thread on a threadpool thread. This runnable will then not be run until the thread is shutting down.
IIRC this was an issue for some utility process work recently, which would intermittently work if the threadpool thread died after the event was dispatched, but wouldn't be run at all if the thread stayed alive.
In order to work around this, we can add an option when creating a new nsThread to ask it to "block dispatch". The idea is that this would prevent dispatching new runnables, as-if it was a non-xpcom thread, unless the runnable is dispatched using NS_DISPATCH_IGNORE_BLOCK_DISPATCH
. Specific places which need to dispatch runnables to that thread (such as to run the initial runnable at thread creation) would set that flag.
This may also help with fixing other issues which may come up when porting code to run on task queues or shared threadpools, rather than on custom thread setups.
Assignee | ||
Comment 1•2 years ago
|
||
Comment 3•2 years ago
|
||
Backed out for causing multiple failures
- Backout link
- Push with failures
- Failure Log1
- Failure line1: gmake[4]: *** [/builds/worker/checkouts/gecko/config/rules.mk:669: Unified_cpp_xpcom_threads1.o] Error 1
- Failure Log2
- Failure line2: PROCESS-CRASH | glterrain | application crashed [@ mozilla::ThreadEventTarget::Dispatch(already_AddRefed<nsIRunnable>, unsigned int)]
- Failure Log3
- Failure line3: Assertion failure: false (Attempt to dispatch to thread which does not usually process dispatched runnables until shutdown), at /builds/worker/checkouts/gecko/xpcom/threads/ThreadEventTarget.cpp:83
Updated•2 years ago
|
Assignee | ||
Comment 4•2 years ago
|
||
Previously this would dispatch to the current thread, which could in
some cases be a threadpool thread, meaning that the runnable would
not run until the threadpool thread exits. This switches the code over
to always dispatch to the StreamTransportService instead.
Depends on D161349
Assignee | ||
Updated•2 years ago
|
Comment 6•2 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/8949a4f0d6ea
https://hg.mozilla.org/mozilla-central/rev/9e56c5c14078
https://hg.mozilla.org/mozilla-central/rev/57813412ce36
Description
•