Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0164d04ec7e4eadc7c63b2ff2689a42e660ef471
      
https://github.com/WebKit/WebKit/commit/0164d04ec7e4eadc7c63b2ff2689a42e660ef471
  Author: Geoffrey Garen <[email protected]>
  Date:   2025-02-20 (Thu, 20 Feb 2025)

  Changed paths:
    M Source/WTF/wtf/BlockPtr.h
    M Source/WTF/wtf/Forward.h
    M Source/WTF/wtf/OSObjectPtr.h
    M Source/WTF/wtf/RetainPtr.h
    M Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp
    M Source/WebKit/Shared/API/APIData.h
    M Source/WebKit/Shared/Cocoa/APIDataCocoa.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/AppPrivacyReport.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm
    M Tools/TestWebKitAPI/cocoa/HTTPServer.h
    M Tools/TestWebKitAPI/cocoa/HTTPServer.mm

  Log Message:
  -----------
  Reduce ODR violations when using Objective-C ARC
https://bugs.webkit.org/show_bug.cgi?id=288032
rdar://145180401

Reviewed by Ryosuke Niwa and David Kilzer.

When an ARC file and a non-ARC file both #include the same header, for each
inline function in the header, the compiler emits two versions — the ARC
version and the non-ARC version.

This includes implicitly generated inline functions like constructors,
assignment operators, and destructors.

Technically, having two versions of an inline function is always a violation of
C++'s "One Definition Rule", and is always undef, even if both functions have
similar behavior ("...each definition of D shall consist of the same sequence
of tokens... implicit calls... shall refer to the same function...")

In practice, you only get a leak or a crash when the ARC version and the non-ARC
version have different behavior, for example:
    * when the function initializes, modifies, or destroys a stored property
    * when the function returns a pointer to an ARC type
    * when the function declares NS_RETURNS_RETAINED or NS_RELEASES_ARGUMENT

Example: rdar://73620184.

I haven’t figured out how to solve this yet.

For now, this patch extends our existing workaround to make mistakes less
likely as we roll out smart pointers across WebKit. Specifically, it gives
makeBlockPtr, RetainPtr, and OSObjectPtr different names in ARC and non-ARC
files. This ensures that their inline functions can’t conflict with each other
across files.

As a consequence, it is no longer possible to pass a RetainPtr argument
from an ARC file to a non-ARC file, or vice-versa.

* Source/WTF/wtf/BlockPtr.h:
* Source/WTF/wtf/Forward.h:
* Source/WTF/wtf/OSObjectPtr.h:
* Source/WTF/wtf/RetainPtr.h:
* Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp:
(WTF::WorkQueueBase::dispatchWithQOS):
* Source/WebKit/Shared/API/APIData.h:
* Source/WebKit/Shared/Cocoa/APIDataCocoa.mm:
(API::Data::createWithoutCopying):

Canonical link: https://commits.webkit.org/290734@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to