From de34cfad585c056553530ce60d9c6bd62d66f5d8 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sun, 6 May 2018 18:14:59 +0200 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/20017 Reviewed-By: Rich Trott Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: Colin Ihrig Reviewed-By: Joyee Cheung --- test/parallel/test-util-inspect.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 5cd051299d7f06..ad5f738a85976b 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -1404,3 +1404,15 @@ util.inspect(process); const args = (function() { return arguments; })('a'); assert.strictEqual(util.inspect(args), "[Arguments] { '0': 'a' }"); } + +{ + // Test that a long linked list can be inspected without throwing an error. + const list = {}; + let head = list; + // The real cutoff value is closer to 1400 stack frames as of May 2018, + // but let's be generous here – even a linked listed of length 100k should be + // inspectable in some way. + for (let i = 0; i < 100000; i++) + head = head.next = {}; + util.inspect(list); +}