Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 152f921e9acfac813163cc430abb7409280d9f91
https://github.com/WebKit/WebKit/commit/152f921e9acfac813163cc430abb7409280d9f91
Author: David Kilzer <[email protected]>
Date: 2026-08-03 (Mon, 03 Aug 2026)
Changed paths:
M Source/WebKit/Platform/IPC/MessageLog.cpp
M Source/WebKit/Platform/IPC/MessageLog.h
M Tools/TestWebKitAPI/Tests/IPC/MessageLogEndToEndTests.cpp
M Tools/TestWebKitAPI/Tests/IPC/MessageLogTests.cpp
Log Message:
-----------
IPC::MessageLog::add() has a data race on the ring buffer element store
<https://bugs.webkit.org/show_bug.cgi?id=320321>
<rdar://183262390>
Reviewed by Kimmo Kinnunen.
Store message names into the ring buffer atomically. Threads that
dispatch IPC never synchronize with one another, and the relaxed
increment of `m_index` orders only the index, so successive writers of
a slot are unordered once the buffer wraps. A relaxed store compiles
to the same instruction as the plain assignment. `std::atomic` is not
constexpr-assignable, so expand the constructor's initializer over an
index sequence to keep `gMessageLog` constant-initialized.
Covered by existing tests. With the element store reverted to a plain
assignment, ThreadSanitizer reports the race in
MessageLogTests.ConcurrentAddWithWrapping.
* Source/WebKit/Platform/IPC/MessageLog.cpp:
* Source/WebKit/Platform/IPC/MessageLog.h:
(IPC::MessageLog::MessageLog):
(IPC::MessageLog::add):
(IPC::MessageLog::atForTesting const): Add.
(IPC::MessageLog::bufferForTesting const): Remove.
(IPC::MessageLog::bufferSize const): Add.
(IPC::MessageLog::capacity const): Add.
(IPC::MessageLog::elementSize const): Add.
* Tools/TestWebKitAPI/Tests/IPC/MessageLogEndToEndTests.cpp:
(TestWebKitAPI::MessageLogEndToEndTest::messageLogContains const):
(TestWebKitAPI::MessageLogEndToEndTest::countMessagesInLog const):
(TestWebKitAPI::MessageLogStreamTest::messageLogContains const):
* Tools/TestWebKitAPI/Tests/IPC/MessageLogTests.cpp:
(TestWebKitAPI::TEST(MessageLogTests, InitialState)):
(TestWebKitAPI::TEST(MessageLogTests, AddSingleMessage)):
(TestWebKitAPI::TEST(MessageLogTests, AddMultipleMessages)):
(TestWebKitAPI::TEST(MessageLogTests, WrapAroundAtCapacity)):
(TestWebKitAPI::TEST(MessageLogTests, MultipleWraps)):
(TestWebKitAPI::TEST(MessageLogTests, ConcurrentAddFromTwoThreads)):
(TestWebKitAPI::TEST(MessageLogTests, ConcurrentAddFromMultipleThreads)):
(TestWebKitAPI::TEST(MessageLogTests, ConcurrentAddWithWrapping)):
Canonical link: https://commits.webkit.org/318465@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications