RESOLVED DUPLICATE of bug 298840298037
Safer CPP static analyzer erroneously claims the use of `dispatch_get_main_queue()`
https://bugs.webkit.org/show_bug.cgi?id=298037
Summary Safer CPP static analyzer erroneously claims the use of `dispatch_get_main_qu...
Jean-Yves Avenard [:jya]
Reported 2025-08-28 07:59:31 PDT
doing something like this ``` [m_synchronizer addPeriodicTimeObserverForInterval:PAL::toCMTime(MediaTime::createWithDouble(3600)) queue:dispatch_get_main_queue() usingBlock:^(CMTime time) { }]; ``` will give "Call argument for parameter 'queue' is unretained and unsafe" the documentation states: ``` * The main queue is a well known global object that is made automatically on * behalf of the main thread during process initialization and is returned by * dispatch_get_main_queue(). This object cannot be modified. Calls to * dispatch_suspend(), dispatch_resume(), dispatch_set_context(), etc., will * have no effect when used on the main queue. */ ``` the object returned will never be deleted during a call as shown above, its use can't possibly be unsafe. An exception should be added. There's currently 377 calls to that method, none wrapping it around a RetainPtr
Attachments
Radar WebKit Bug Importer
Comment 1 2025-08-28 07:59:41 PDT
Ryosuke Niwa
Comment 2 2025-09-15 21:59:09 PDT
We added a wrapping function in the bug 298840. *** This bug has been marked as a duplicate of bug 298840 ***
Chris Dumez
Comment 3 2025-09-15 21:59:42 PDT
Bug 298840 introduced `mainDispatchQueueSingleton()` in wtf/darwin/DispatchExtras.h, which should now be used instead.
Note You need to log in before you can comment on or make changes to this bug.