Looking at [one of the crashes](https://crash-stats.mozilla.org/report/index/965a417e-9026-4568-94cb-1782d0210921), I arrived at [`nsThread::ShutdownInternal`](https://searchfox.org/mozilla-central/rev/50c3cf7a3c931409b54efa009795b69c19383541/xpcom/threads/nsThread.cpp#781-782) where I read: ``` // XXXroc What if posting the event fails due to OOM? mEvents->PutEvent(event.forget(), EventQueuePriority::Normal); ``` Inside `PutEvent`, there seem to be more than just OOM conditions that might have us return `false` here. Shouldn't we check for `false` and in case return a `nullptr` as shutdown context (which would us not make enter the [`SpinEventLoopUntil`](https://searchfox.org/mozilla-central/rev/50c3cf7a3c931409b54efa009795b69c19383541/xpcom/threads/nsThread.cpp#840-841) that apparently waits forever for a flag on the shutdown context to be set) ? Randell, WDYT ?
Bug 1629669 Comment 16 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
Looking at [one of the crashes](https://crash-stats.mozilla.org/report/index/965a417e-9026-4568-94cb-1782d0210921), I arrived at [`nsThread::ShutdownInternal`](https://searchfox.org/mozilla-central/rev/50c3cf7a3c931409b54efa009795b69c19383541/xpcom/threads/nsThread.cpp#781-782) where I read: ``` // XXXroc What if posting the event fails due to OOM? mEvents->PutEvent(event.forget(), EventQueuePriority::Normal); ``` Inside `PutEvent`, there seem to be more than just OOM conditions that might have us return `false` here. Shouldn't we check for `false` and in case return a `nullptr` as shutdown context (which would us not make enter the [`SpinEventLoopUntil`](https://searchfox.org/mozilla-central/rev/50c3cf7a3c931409b54efa009795b69c19383541/xpcom/threads/nsThread.cpp#840-841) that apparently waits forever for a flag on the shutdown context to be set) ? It also seems that we [sequentially shut down the threads](https://searchfox.org/mozilla-central/rev/50c3cf7a3c931409b54efa009795b69c19383541/xpcom/threads/nsThreadManager.cpp#411-413), waiting for each thread to join before we shut down the next. We might want to decouple the sending of the shutdown event to all threads from the waiting for the threads to join. Randell, WDYT ?