1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_5/Regress/regress-96128-n.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,51 @@ 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 + * Date: 29 Aug 2001 1.11 + * 1.12 + * SUMMARY: Negative test that JS infinite recursion protection works. 1.13 + * We expect the code here to fail (i.e. exit code 3), but NOT crash. 1.14 + * 1.15 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=96128 1.16 + */ 1.17 +//----------------------------------------------------------------------------- 1.18 +var BUGNUMBER = 96128; 1.19 +var summary = 'Testing that JS infinite recursion protection works'; 1.20 + 1.21 + 1.22 +function objRecurse() 1.23 +{ 1.24 + /* 1.25 + * jband: 1.26 + * 1.27 + * Causes a stack overflow crash in debug builds of both the browser 1.28 + * and the shell. In the release builds this is safely caught by the 1.29 + * "too much recursion" mechanism. If I remove the 'new' from the code below 1.30 + * this is safely caught in both debug and release builds. The 'new' causes a 1.31 + * lookup for the Constructor name and seems to (at least) double the number 1.32 + * of items on the C stack for the given interpLevel depth. 1.33 + */ 1.34 + return new objRecurse(); 1.35 +} 1.36 + 1.37 + 1.38 + 1.39 +//----------------------------------------------------------------------------- 1.40 +test(); 1.41 +//----------------------------------------------------------------------------- 1.42 + 1.43 + 1.44 +function test() 1.45 +{ 1.46 + enterFunc ('test'); 1.47 + printBugNumber(BUGNUMBER); 1.48 + printStatus (summary); 1.49 + 1.50 + // we expect this to fail (exit code 3), but NOT crash. - 1.51 + var obj = new objRecurse(); 1.52 + 1.53 + exitFunc ('test'); 1.54 +}