Open Bug 1676905 Opened 4 years ago Updated 3 years ago

Refactor NS_NewNamedThread uses with initial events

Categories

(Core :: XPCOM, enhancement)

enhancement

Tracking

()

People

(Reporter: KrisWright, Unassigned)

References

(Blocks 1 open bug)

Details

We want to get rid of the entire aInitialEvent use, here:
https://searchfox.org/mozilla-central/rev/c409dd9235c133ab41eba635f906aa16e050c197/xpcom/threads/nsThreadUtils.cpp#156,158,177-182

A lot of calls that use the initial event just pass a nullptr and those that do use it can be refactored to simply dispatch the call after creating a new thread. Bug 1506812 has a bit of extra information on things that can go wrong with the NS_NewNamedThread startup order. Since threads are written to after the initial task dispatches, threads are capable of racing on write during creation. If the initial event tries to read into the thread or shut down the thread it's capable of racing with the initializer. It makes more sense to change these NS_NewNamedThread calls to simply dispatch their initial event after actual thread initialization.

Blocks: tsan
You need to log in before you can comment on or make changes to this bug.