From ae0e8bf749558df0baae17db929175bec734ea7c Mon Sep 17 00:00:00 2001 From: Carl Woffenden Date: Thu, 31 Oct 2024 16:52:38 +0100 Subject: [PATCH] Explicitly assert any changes to the stack address --- src/audio_worklet.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/audio_worklet.js b/src/audio_worklet.js index 5367cd75dda23..b9223ab6a9ee3 100644 --- a/src/audio_worklet.js +++ b/src/audio_worklet.js @@ -64,6 +64,11 @@ function createWasmAudioWorkletProcessor(audioParams) { ); } stackRestore(oldStackPtr); + +#if ASSERTIONS + // Explicitly verify this later in process() + this.ctorOldStackPtr = oldStackPtr; +#endif } static get parameterDescriptors() { @@ -92,6 +97,7 @@ function createWasmAudioWorkletProcessor(audioParams) { for (i in parameters) stackMemoryNeeded += parameters[i].byteLength + {{{ C_STRUCTS.AudioParamFrame.__size__ }}}, ++numParams; #if ASSERTIONS + console.assert(oldStackPtr == this.ctorOldStackPtr, 'AudioWorklet stack address has unexpectedly moved'); console.assert(outputViewsNeeded <= this.outputViews.length, `Too many AudioWorklet outputs (need ${outputViewsNeeded} but have stack space for ${this.outputViews.length})`); #endif