1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_5/extensions/regress-341956-02.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,55 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +//----------------------------------------------------------------------------- 1.10 +var BUGNUMBER = 341956; 1.11 +var summary = 'GC Hazards in jsarray.c - pop'; 1.12 +var actual = ''; 1.13 +var expect = 'GETTER RESULT'; 1.14 + 1.15 +//----------------------------------------------------------------------------- 1.16 +test(); 1.17 +//----------------------------------------------------------------------------- 1.18 + 1.19 +function test() 1.20 +{ 1.21 + enterFunc ('test'); 1.22 + printBugNumber(BUGNUMBER); 1.23 + printStatus (summary); 1.24 + 1.25 + var N = 0xFFFFFFFF; 1.26 + var a = []; 1.27 + a[N - 1] = 0; 1.28 + 1.29 + var expected = "GETTER RESULT"; 1.30 + 1.31 + a.__defineGetter__(N - 1, function() { 1.32 + delete a[N - 1]; 1.33 + var tmp = []; 1.34 + tmp[N - 2] = 1; 1.35 + 1.36 + if (typeof gc == 'function') 1.37 + gc(); 1.38 + for (var i = 0; i != 50000; ++i) { 1.39 + var tmp = 1 / 3; 1.40 + tmp /= 10; 1.41 + } 1.42 + for (var i = 0; i != 1000; ++i) { 1.43 + // Make string with 11 characters that would take 1.44 + // (11 + 1) * 2 bytes or sizeof(JSAtom) so eventually 1.45 + // malloc will ovewrite just freed atoms. 1.46 + var tmp2 = Array(12).join(' '); 1.47 + } 1.48 + return expected; 1.49 + }); 1.50 + 1.51 + actual = a.pop(); 1.52 + 1.53 + reportCompare(expect, actual, summary); 1.54 + 1.55 + print('Done'); 1.56 + 1.57 + exitFunc ('test'); 1.58 +}