Many potential leaks if |NS_DispatchToMain| fails

NEW
Unassigned

Status

()

Core
XPCOM
3 years ago
3 years ago

People

(Reporter: erahm, Unassigned)

Tracking

(Depends on: 1 bug, {coverity})

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [MemShrink:P2][CID 1286725][CID 1285940][CID 1285967][CID 1285977][CID 1286098][CID 1286118][CID 1286131][CID 1286158][CID 1286193][CID 1286214][CID 1286251][CID 1286254][CID 1286283][CID 1286288][CID 1286326][CID 1286392][CID 1286465][CID 1286484]…)

Coverity indicates there are 72 potential leaks in calls to |NS_DispatchToMainThread|. A quick grep of the codebase indicates there are probably at least 158.

Previously |NS_DispatchToCurrentThread| was fixed to use a deathGrip on the passed in runnable, but |NS_DispatchToMainThread| was left as-is, due to:

> // In the case of failure with a newly allocated runnable with a
> // refcount of zero, we intentionally leak the runnable, because it is
> // likely that the runnable is being dispatched to the main thread
> // because it owns main thread only objects, so it is not safe to
> // release them here.

AFAICT the majority of code does not behave in this way, but a more thorough survey should be performed. Most often the runnable passed in is a simple struct that calls a function in the main thread context.

Possible options:
- Add a deathGrip to |NS_DispatchToMainThread|
- Update all callers to hold an nsComPtr/nsRefPtr to the passed in runnable
- Do something to make coverity ignore this function
Whiteboard: [MemShrink][CID 1286725][CID 1285940][CID 1285967][CID 1285977][CID 1286098][CID 1286118][CID 1286131][CID 1286158][CID 1286193][CID 1286214][CID 1286251][CID 1286254][CID 1286283][CID 1286288][CID 1286326][CID 1286392][CID 1286465][CID 1286484][CI… → [MemShrink:P2][CID 1286725][CID 1285940][CID 1285967][CID 1285977][CID 1286098][CID 1286118][CID 1286131][CID 1286158][CID 1286193][CID 1286214][CID 1286251][CID 1286254][CID 1286283][CID 1286288][CID 1286326][CID 1286392][CID 1286465][CID 1286484]…
Everyone agreed making NS_DispatchToMain infallible is the best path forward here.
Whiteboard: [MemShrink:P2][CID 1286725][CID 1285940][CID 1285967][CID 1285977][CID 1286098][CID 1286118][CID 1286131][CID 1286158][CID 1286193][CID 1286214][CID 1286251][CID 1286254][CID 1286283][CID 1286288][CID 1286326][CID 1286392][CID 1286465][CID 1286484]… → [MemShrink:P2][CID 1286725][CID 1285940][CID 1285967][CID 1285977][CID 1286098][CID 1286118][CID 1286131][CID 1286158][CID 1286193][CID 1286214][CID 1286251][CID 1286254][CID 1286283][CID 1286288][CID 1286326][CID 1286392][CID 1286465][CID 1286484]…
Whiteboard: [MemShrink:P2][CID 1286725][CID 1285940][CID 1285967][CID 1285977][CID 1286098][CID 1286118][CID 1286131][CID 1286158][CID 1286193][CID 1286214][CID 1286251][CID 1286254][CID 1286283][CID 1286288][CID 1286326][CID 1286392][CID 1286465][CID 1286484]… → [MemShrink:P2][CID 1286725][CID 1285940][CID 1285967][CID 1285977][CID 1286098][CID 1286118][CID 1286131][CID 1286158][CID 1286193][CID 1286214][CID 1286251][CID 1286254][CID 1286283][CID 1286288][CID 1286326][CID 1286392][CID 1286465][CID 1286484]…
Whiteboard: [MemShrink:P2][CID 1286725][CID 1285940][CID 1285967][CID 1285977][CID 1286098][CID 1286118][CID 1286131][CID 1286158][CID 1286193][CID 1286214][CID 1286251][CID 1286254][CID 1286283][CID 1286288][CID 1286326][CID 1286392][CID 1286465][CID 1286484]… → [MemShrink:P2][CID 1286725][CID 1285940][CID 1285967][CID 1285977][CID 1286098][CID 1286118][CID 1286131][CID 1286158][CID 1286193][CID 1286214][CID 1286251][CID 1286254][CID 1286283][CID 1286288][CID 1286326][CID 1286392][CID 1286465][CID 1286484]…
Depends on: 1142799
Whiteboard: [MemShrink:P2][CID 1286725][CID 1285940][CID 1285967][CID 1285977][CID 1286098][CID 1286118][CID 1286131][CID 1286158][CID 1286193][CID 1286214][CID 1286251][CID 1286254][CID 1286283][CID 1286288][CID 1286326][CID 1286392][CID 1286465][CID 1286484]… → [MemShrink:P2][CID 1286725][CID 1285940][CID 1285967][CID 1285977][CID 1286098][CID 1286118][CID 1286131][CID 1286158][CID 1286193][CID 1286214][CID 1286251][CID 1286254][CID 1286283][CID 1286288][CID 1286326][CID 1286392][CID 1286465][CID 1286484]…
Whiteboard: [MemShrink:P2][CID 1286725][CID 1285940][CID 1285967][CID 1285977][CID 1286098][CID 1286118][CID 1286131][CID 1286158][CID 1286193][CID 1286214][CID 1286251][CID 1286254][CID 1286283][CID 1286288][CID 1286326][CID 1286392][CID 1286465][CID 1286484]… → [MemShrink:P2][CID 1286725][CID 1285940][CID 1285967][CID 1285977][CID 1286098][CID 1286118][CID 1286131][CID 1286158][CID 1286193][CID 1286214][CID 1286251][CID 1286254][CID 1286283][CID 1286288][CID 1286326][CID 1286392][CID 1286465][CID 1286484]…
You need to log in before you can comment on or make changes to this bug.