Title: [281001] trunk/Source/WebCore
Revision
281001
Author
[email protected]
Date
2021-08-12 18:13:17 -0700 (Thu, 12 Aug 2021)

Log Message

ThreadSanitizer: data race in WebCore::CARingBufferStorageVector::setCurrentFrameBounds() / getCurrentFrameBounds()
<https://webkit.org/b/229014>
<rdar://problem/81817224>

Reviewed by Chris Dumez.

This turned out to be a false-positive since reads and writes
are protected differently, and it's okay if a read returns data
from the ring buffer that is one slot older than the current
write.

Covered by layout tests running with TSan:
    fast/mediastream/getUserMedia-webaudio.html
    fast/mediastream/mediastreamtrack-audio-clone.html
    imported/w3c/web-platform-tests/webrtc/RTCDTMFSender-insertDTMF.https.html
    imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-iceConnectionState.https.html
    imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-track-stats.https.html
    imported/w3c/web-platform-tests/webrtc/protocol/missing-fields.html
    webrtc/audio-peer-connection-g722.html
    webrtc/audio-peer-connection-webaudio.html
    webrtc/audio-replace-track.html
    webrtc/peer-connection-audio-mute.html
    webrtc/peer-connection-audio-mute2.html
    webrtc/peer-connection-createMediaStreamDestination.html
    webrtc/peer-connection-remote-audio-mute.html
    webrtc/peer-connection-remote-audio-mute2.html

* platform/audio/cocoa/CARingBuffer.cpp:
(WebCore::CARingBufferStorageVector::getCurrentFrameBounds):
(WebCore::CARingBufferStorageVector::currentStartFrame const):
(WebCore::CARingBufferStorageVector::currentEndFrame const):
- Add SUPPRESS_TSAN attribute since reads are protected by
  std::atomic<int32_t> m_timeBoundsQueuePtr only being
  incremented after the next m_timeBoundsQueue slot is updated.
  Writes are potected by
  Locker locker { m_currentFrameBoundsLock }.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (281000 => 281001)


--- trunk/Source/WebCore/ChangeLog	2021-08-13 00:36:04 UTC (rev 281000)
+++ trunk/Source/WebCore/ChangeLog	2021-08-13 01:13:17 UTC (rev 281001)
@@ -1,3 +1,42 @@
+2021-08-12  David Kilzer  <[email protected]>
+
+        ThreadSanitizer: data race in WebCore::CARingBufferStorageVector::setCurrentFrameBounds() / getCurrentFrameBounds()
+        <https://webkit.org/b/229014>
+        <rdar://problem/81817224>
+
+        Reviewed by Chris Dumez.
+
+        This turned out to be a false-positive since reads and writes
+        are protected differently, and it's okay if a read returns data
+        from the ring buffer that is one slot older than the current
+        write.
+
+        Covered by layout tests running with TSan:
+            fast/mediastream/getUserMedia-webaudio.html
+            fast/mediastream/mediastreamtrack-audio-clone.html
+            imported/w3c/web-platform-tests/webrtc/RTCDTMFSender-insertDTMF.https.html
+            imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-iceConnectionState.https.html
+            imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-track-stats.https.html
+            imported/w3c/web-platform-tests/webrtc/protocol/missing-fields.html
+            webrtc/audio-peer-connection-g722.html
+            webrtc/audio-peer-connection-webaudio.html
+            webrtc/audio-replace-track.html
+            webrtc/peer-connection-audio-mute.html
+            webrtc/peer-connection-audio-mute2.html
+            webrtc/peer-connection-createMediaStreamDestination.html
+            webrtc/peer-connection-remote-audio-mute.html
+            webrtc/peer-connection-remote-audio-mute2.html
+
+        * platform/audio/cocoa/CARingBuffer.cpp:
+        (WebCore::CARingBufferStorageVector::getCurrentFrameBounds):
+        (WebCore::CARingBufferStorageVector::currentStartFrame const):
+        (WebCore::CARingBufferStorageVector::currentEndFrame const):
+        - Add SUPPRESS_TSAN attribute since reads are protected by
+          std::atomic<int32_t> m_timeBoundsQueuePtr only being
+          incremented after the next m_timeBoundsQueue slot is updated.
+          Writes are potected by
+          Locker locker { m_currentFrameBoundsLock }.
+
 2021-08-12  Alex Christensen  <[email protected]>
 
         Unreviewed, reverting r280977.

Modified: trunk/Source/WebCore/platform/audio/cocoa/CARingBuffer.cpp (281000 => 281001)


--- trunk/Source/WebCore/platform/audio/cocoa/CARingBuffer.cpp	2021-08-13 00:36:04 UTC (rev 281000)
+++ trunk/Source/WebCore/platform/audio/cocoa/CARingBuffer.cpp	2021-08-13 01:13:17 UTC (rev 281001)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -325,7 +325,7 @@
     m_buffers->getCurrentFrameBounds(startFrame, endFrame);
 }
 
-void CARingBufferStorageVector::getCurrentFrameBounds(uint64_t& startFrame, uint64_t& endFrame)
+SUPPRESS_TSAN void CARingBufferStorageVector::getCurrentFrameBounds(uint64_t& startFrame, uint64_t& endFrame)
 {
     uint32_t curPtr = m_timeBoundsQueuePtr.load();
     uint32_t index = curPtr & kGeneralRingTimeBoundsQueueMask;
@@ -357,7 +357,7 @@
     return m_buffers->currentStartFrame();
 }
 
-uint64_t CARingBufferStorageVector::currentStartFrame() const
+SUPPRESS_TSAN uint64_t CARingBufferStorageVector::currentStartFrame() const
 {
     uint32_t index = m_timeBoundsQueuePtr.load() & kGeneralRingTimeBoundsQueueMask;
     return m_timeBoundsQueue[index].m_startFrame;
@@ -368,7 +368,7 @@
     return m_buffers->currentEndFrame();
 }
 
-uint64_t CARingBufferStorageVector::currentEndFrame() const
+SUPPRESS_TSAN uint64_t CARingBufferStorageVector::currentEndFrame() const
 {
     uint32_t index = m_timeBoundsQueuePtr.load() & kGeneralRingTimeBoundsQueueMask;
     return m_timeBoundsQueue[index].m_endFrame;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to