Skip to content

Commit

Permalink
Explicitly assert any changes to the stack address
Browse files Browse the repository at this point in the history
  • Loading branch information
cwoffenden committed Oct 31, 2024
1 parent 9e5c73b commit 069f7a4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/audio_worklet.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ function createWasmAudioWorkletProcessor(audioParams) {
);
}
stackRestore(oldStackPtr);

#if ASSERTIONS
// Explicitly verify this later in process()
this.ctorOldStackPtr = oldStackPtr;
#endif
}

static get parameterDescriptors() {
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 069f7a4

Please sign in to comment.