Closed Bug 2059549 Opened 4 months ago Closed 4 months ago

Stop warning on the expected NS_GetMainThread failure in NS_DispatchToMainThread

Categories

(Core :: XPCOM, task)

task

Tracking

()

RESOLVED DUPLICATE of bug 2055964

People

(Reporter: Sylvestre, Assigned: Sylvestre)

Details

Attachments

(1 obsolete file)

Number one warning with 15 089 880 occurrences per day

NS_DispatchToMainThread wraps its NS_GetMainThread result in NS_WARN_IF(NS_FAILED(rv)). The only failure that can produce is nsThreadManager::GetMainThread returning NS_ERROR_NOT_INITIALIZED when mMainThread is null, which happens only before XPCOM initialization or after ReleaseMainThread during shutdown. The NS_ASSERTION on the next line already covers this and says so: "Failed NS_DispatchToMainThread() in shutdown; leaking".

The warning adds nothing, since NS_WARN_IF prints just the stringified condition 'NS_FAILED(rv)', yet it is one of the most frequent C++ warnings in debug test runs.

Drop the NS_WARN_IF wrapper and keep the plain NS_FAILED test. The NS_ASSERTION still fires when the dispatch was not NS_DISPATCH_FALLIBLE and the runnable is leaked, and nsThreadManager::GetMainThread keeps its own informative warning for the off-main-thread case.

NS_DispatchToMainThread wraps its NS_GetMainThread result in
NS_WARN_IF(NS_FAILED(rv)). The only failure that can produce is
nsThreadManager::GetMainThread returning NS_ERROR_NOT_INITIALIZED when
mMainThread is null, which happens only before XPCOM initialization or after
ReleaseMainThread during shutdown. The NS_ASSERTION on the next line already
covers this case and says so: "Failed NS_DispatchToMainThread() in shutdown;
leaking".

The warning adds nothing, since NS_WARN_IF prints just the stringified condition
'NS_FAILED(rv)', yet it is one of the most frequent C++ warnings of debug test
runs.

Drop the NS_WARN_IF wrapper and keep the plain NS_FAILED test. NS_WARN_IF is
DEBUG-only, so release builds are unaffected. The NS_ASSERTION still fires when
the dispatch was not NS_DISPATCH_FALLIBLE and the runnable is therefore leaked,
and nsThreadManager::GetMainThread keeps its own informative warning for the
off-main-thread case.

Assignee: nobody → sledru
Status: NEW → ASSIGNED

This is already on file as bug 2055964, with an r+'ed patch.

Status: ASSIGNED → RESOLVED
Closed: 4 months ago
Duplicate of bug: 2055964
Resolution: --- → DUPLICATE
Attachment #9620067 - Attachment is obsolete: true

Thank you for filing this. If you are going to file more bugs about the top sources of warning on the new dashboard, please check over the recentish bugs filed against bug 765224, which contains a lot of the top NS_WARNINGs that I have seen over the last year or two.

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

Attachment

General

Created:
Updated:
Size: