Skip to content

Commit

Permalink
test: make sure linked lists are inspectable with defaults
Browse files Browse the repository at this point in the history
Make sure that a long singly-linked list can be passed
to `util.inspect()` without causing a stack overflow.

PR-URL: #20017
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
  • Loading branch information
addaleax authored and targos committed May 12, 2018
1 parent de06115 commit de34cfa
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/parallel/test-util-inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit de34cfa

Please sign in to comment.