Debian Codegraph @

rhino/testsrc/tests/js1_5/extensions/regress-341956-01.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 var gTestfile = 'regress-341956-01.js';
7 //-----------------------------------------------------------------------------
8 var BUGNUMBER = 341956;
9 var summary = 'GC Hazards in jsarray.c - unshift';
10 var actual = 'No Crash';
11 var expect = 'No Crash';
12
13 //-----------------------------------------------------------------------------
14 test();
15 //-----------------------------------------------------------------------------
16
17 function test()
18 {
19 enterFunc ('test');
20 printBugNumber(BUGNUMBER);
21 printStatus (summary);
22
23 var N = 0xFFFFFFFF;
24
25 var a = [];
26 a[N - 1] = 1;
27 a.__defineGetter__(N - 1, function() {
28 var tmp = [];
29 tmp[N - 2] = 0;
30 if (typeof gc == 'function')
31 gc();
32 for (var i = 0; i != 50000; ++i) {
33 var tmp = 1 / 3;
34 tmp /= 10;
35 }
36 for (var i = 0; i != 1000; ++i) {
37 // Make string with 11 characters that would take
38 // (11 + 1) * 2 bytes or sizeof(JSAtom) so eventually
39 // malloc will ovewrite just freed atoms.
40 var tmp2 = Array(12).join(' ');
41 }
42 return 10;
43 });
44
45
46 // The following always-throw getter is to stop unshift from doing
47 // 2^32 iterations.
48 var toStop = "stringToStop";
49 a[N - 3] = 0;
50 a.__defineGetter__(N - 3, function() { throw toStop; });
51
52 var good = false;
53
54 try {
55 a.unshift(1);
56 } catch (e) {
57 if (e === toStop)
58 good = true;
59 }
60
61 expect = true;
62 actual = good;
63
64 reportCompare(expect, actual, summary);
65
66 print('Done');
67
68 exitFunc ('test');
69 }