Skip to content

Commit 5096e24

Browse files
addaleaxBridgeAR
authored andcommitted
test: make sure linked lists are inspectable with defaults
Make sure that a long singly-linked list can be passed to `util.inspect()` without causing a stack overflow. PR-URL: nodejs#20017 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
1 parent 849aaae commit 5096e24

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/parallel/test-util-inspect.js

+12
Original file line numberDiff line numberDiff line change
@@ -1404,3 +1404,15 @@ util.inspect(process);
14041404
const args = (function() { return arguments; })('a');
14051405
assert.strictEqual(util.inspect(args), "[Arguments] { '0': 'a' }");
14061406
}
1407+
1408+
{
1409+
// Test that a long linked list can be inspected without throwing an error.
1410+
const list = {};
1411+
let head = list;
1412+
// The real cutoff value is closer to 1400 stack frames as of May 2018,
1413+
// but let's be generous here – even a linked listed of length 100k should be
1414+
// inspectable in some way.
1415+
for (let i = 0; i < 100000; i++)
1416+
head = head.next = {};
1417+
util.inspect(list);
1418+
}

0 commit comments

Comments
 (0)