Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 8912cf5b00c44e5c81ba047c9b3ec32f4135d437
https://github.com/WebKit/WebKit/commit/8912cf5b00c44e5c81ba047c9b3ec32f4135d437
Author: Ruthvik Konda <[email protected]>
Date: 2026-07-02 (Thu, 02 Jul 2026)
Changed paths:
A
LayoutTests/webaudio/WaveShaper/waveshaper-curve-getter-during-rendering-crash-expected.txt
A
LayoutTests/webaudio/WaveShaper/waveshaper-curve-getter-during-rendering-crash.html
M Source/WebCore/Modules/webaudio/WaveShaperDSPKernel.cpp
M Source/WebCore/Modules/webaudio/WaveShaperNode.cpp
M Source/WebCore/Modules/webaudio/WaveShaperNode.h
M Source/WebCore/Modules/webaudio/WaveShaperProcessor.cpp
M Source/WebCore/Modules/webaudio/WaveShaperProcessor.h
Log Message:
-----------
[WebCore] Store WaveShaperProcessor curve as Vector<float> to avoid
cross-thread RefCounted race
https://bugs.webkit.org/show_bug.cgi?id=313528
rdar://175171873
Reviewed by Chris Dumez.
WaveShaperProcessor::m_curve was a RefPtr<Float32Array>. Float32Array inherits
RefCounted<ArrayBufferView>, whose refcount is non-atomic. 296577@main changed
the audio-thread readers in WaveShaperDSPKernel::processCurve and
WaveShaperNode::propagatesSilence to wrap waveShaperProcessor()->curve() in a
local RefPtr; the main-thread getter WaveShaperNode::curveForBindings() already
did the same lockless. The concurrent non-atomic ref/deref races; a lost
increment leaves the count one too low; a subsequent deref frees m_curve out
from under the processor; the next render quantum is a heap-use-after-free in
processCurve.
On builds with ENABLE(SECURITY_ASSERTIONS), RefCountDebugger's threading
checker traps first; on plain Release the UAF is reachable from web content via
OfflineAudioContext + the WaveShaperNode.curve getter.
Fix by storing the curve as Vector<float> instead of RefPtr<Float32Array>. The
internal curve was already cloned on set and on get, so the Float32Array wrapper
was vestigial. With a Vector there is no RefCounted object on the audio-thread
path; m_processLock continues to guard buffer replacement against audio-thread
reads. This matches AudioParamTimeline::ParamEvent::m_curve and
IIRProcessor::m_feedforward.
Test: webaudio/WaveShaper/waveshaper-curve-getter-during-rendering-crash.html
*
LayoutTests/webaudio/WaveShaper/waveshaper-curve-getter-during-rendering-crash-expected.txt:
Added.
*
LayoutTests/webaudio/WaveShaper/waveshaper-curve-getter-during-rendering-crash.html:
Added.
* Source/WebCore/Modules/webaudio/WaveShaperDSPKernel.cpp:
(WebCore::WaveShaperDSPKernel::processCurve):
* Source/WebCore/Modules/webaudio/WaveShaperNode.cpp:
(WebCore::WaveShaperNode::setCurveForBindings):
(WebCore::WaveShaperNode::curveForBindings):
(WebCore::WaveShaperNode::propagatesSilence const):
* Source/WebCore/Modules/webaudio/WaveShaperNode.h:
* Source/WebCore/Modules/webaudio/WaveShaperProcessor.cpp:
(WebCore::WaveShaperProcessor::setCurveForBindings):
* Source/WebCore/Modules/webaudio/WaveShaperProcessor.h:
(WebCore::WaveShaperProcessor::curveForBindings const):
(WebCore::WaveShaperProcessor::curve const):
(WebCore::WaveShaperProcessor::curveForBindings): Deleted.
Originally-landed-as: 305413.793@safari-7624-branch (0dcea6bac528).
rdar://181076704
Canonical link: https://commits.webkit.org/316385@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications