11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_cirequire('../common');
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst assert = require('assert');
61cb0ef41Sopenharmony_ciconst { spawnSync } = require('child_process');
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci// The default --stack-size is 984, which is below Windows' default stack size
91cb0ef41Sopenharmony_ci// limit of 1 MiB. However, even a slight increase would cause node to exceed
101cb0ef41Sopenharmony_ci// the 1 MiB limit and thus to crash with the exit code STATUS_STACK_OVERFLOW.
111cb0ef41Sopenharmony_ci// Newer versions of Node.js allow the stack size to grow to up to 8 MiB, which
121cb0ef41Sopenharmony_ci// better aligns with default limits on other platforms and which is commonly
131cb0ef41Sopenharmony_ci// used for browsers on Windows.
141cb0ef41Sopenharmony_ci// See https://github.com/nodejs/node/issues/43630.
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ciconst { status, signal, stderr } = spawnSync(process.execPath, [
171cb0ef41Sopenharmony_ci  '--stack-size=2000',
181cb0ef41Sopenharmony_ci  '-e',
191cb0ef41Sopenharmony_ci  '(function explode() { return explode(); })()',
201cb0ef41Sopenharmony_ci], {
211cb0ef41Sopenharmony_ci  encoding: 'utf8'
221cb0ef41Sopenharmony_ci});
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_ciassert.strictEqual(status, 1);
251cb0ef41Sopenharmony_ciassert.strictEqual(signal, null);
261cb0ef41Sopenharmony_ciassert.match(stderr, /Maximum call stack size exceeded/);
27