From 692fb8ab211c65a06d17c452106447ea590386d9 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Mon, 31 May 2021 09:22:26 +0200 Subject: [PATCH] print trace for potential cycle, https://github.com/microsoft/vscode/issues/124723#issuecomment-850674813 --- src/vs/base/common/map.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/vs/base/common/map.ts b/src/vs/base/common/map.ts index 36d543ee934a9..1b2c47f51f2c9 100644 --- a/src/vs/base/common/map.ts +++ b/src/vs/base/common/map.ts @@ -497,10 +497,14 @@ export class TernarySearchTree { yield* this._entries(this._root); } - private *_entries(node: TernarySearchTreeNode | undefined): IterableIterator<[K, V]> { + private *_entries(node: TernarySearchTreeNode | undefined, i: number = 0): IterableIterator<[K, V]> { + if (i > 5000) { + console.trace('potential CYCLE detected'); + return; + } if (node) { // left - yield* this._entries(node.left); + yield* this._entries(node.left, i++); // node if (node.value) { @@ -508,10 +512,10 @@ export class TernarySearchTree { yield [node.key, node.value]; } // mid - yield* this._entries(node.mid); + yield* this._entries(node.mid, i++); // right - yield* this._entries(node.right); + yield* this._entries(node.right, i++); } } }