From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- js/src/tests/non262/extensions/clone-sab.js | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 js/src/tests/non262/extensions/clone-sab.js (limited to 'js/src/tests/non262/extensions/clone-sab.js') diff --git a/js/src/tests/non262/extensions/clone-sab.js b/js/src/tests/non262/extensions/clone-sab.js new file mode 100644 index 0000000000..3b35f90abc --- /dev/null +++ b/js/src/tests/non262/extensions/clone-sab.js @@ -0,0 +1,31 @@ +// |reftest| skip-if(!xulRuntime.shell) +/* -*- Mode: js2; tab-width: 40; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * Any copyright is dedicated to the Public Domain. + * https://creativecommons.org/publicdomain/zero/1.0/ + */ + +// Deserialize a serialization buffer containing a reference to a +// SharedArrayBuffer buffer object enough times and we will crash because of a +// reference counting bug. + +if (!this.SharedArrayBuffer) { + reportCompare(true,true); + quit(0); +} + +let x = new SharedArrayBuffer(1); +let y = serialize(x, [], {SharedArrayBuffer: 'allow'}); +x = null; + +// If the bug is present this loop usually crashes quickly during +// deserialization because the memory has become unmapped. + +for (let i=0 ; i < 50 ; i++ ) { + let obj = deserialize(y, {SharedArrayBuffer: 'allow'}); + let z = new Int8Array(obj); + z[0] = 0; +} + +reportCompare(true, true); + -- cgit v1.2.3