Summary: | False positive warning when building RefCounter test with GCC 12 | ||
---|---|---|---|
Product: | WebKit | Reporter: | Michael Catanzaro <mcatanzaro> |
Component: | Tools / Tests | Assignee: | Michael Catanzaro <mcatanzaro> |
Status: | RESOLVED FIXED | ||
Severity: | Normal | CC: | mcatanzaro, webkit-bug-importer |
Priority: | P2 | Keywords: | InRadar |
Version: | WebKit Nightly Build | ||
Hardware: | PC | ||
OS: | Linux |
Description
Michael Catanzaro
2022-04-14 08:55:31 PDT
This warning is a false positive. m_refCounter is nullptr at this point. RefCounter<T>::~RefCounter calls m_count->refCounterWasDeleted(), which sets m_refCounter = nullptr. It's a poor man's WeakPtr, basically. I instrumented the code with some WTFLogAlways and it looks like everything is going fine, so I will suppress this warning. Actually wait, I only checked the first of the two warnings. As usual, I commented too soon. The second warning relates to m_value, not m_refCounter. The only way this could go wrong is if the Counter object itself is already invalid when its member function is called. I highly doubt that is happening, but will add more instrumentation to check this case as well, just to be completely sure. (If that does happen, then it would explain the first warning as well.) I think we're fine: // Testing (3g) - deref with callback from 1 -> 0 AFTER RefCounter has been destroyed. deref: this=0x20cdd10 ~Count this=0x20cdd10 // Testing (1b) - Construction without a callback. The use after free would happen if ~Count were somehow destroyed before Count::deref is called. The opposite is happening. Seems good. Pull request: https://github.com/WebKit/WebKit/pull/605 Committed r294157 (250527@main): <https://commits.webkit.org/250527@main> Reviewed commits have been landed. Closing PR #605 and removing active labels. |