From 9471b5f964395f9b4f4f673239d4375e1910bfaa Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Wed, 12 Jul 2023 01:01:18 +0800 Subject: [PATCH] fixes #22256; fixes GC_disableOrc overflow (#22257) --- lib/system/orc.nim | 2 +- tests/gc/tdisable_orc.nim | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/gc/tdisable_orc.nim diff --git a/lib/system/orc.nim b/lib/system/orc.nim index 1935407102..b7b98c3404 100644 --- a/lib/system/orc.nim +++ b/lib/system/orc.nim @@ -411,7 +411,7 @@ proc registerCycle(s: Cell; desc: PNimTypeV2) = if roots.d == nil: init(roots) add(roots, s, desc) - if roots.len >= rootsThreshold+defaultThreshold: + if roots.len - defaultThreshold >= rootsThreshold: collectCycles() when logOrc: writeCell("[added root]", s, desc) diff --git a/tests/gc/tdisable_orc.nim b/tests/gc/tdisable_orc.nim new file mode 100644 index 0000000000..b5f161c791 --- /dev/null +++ b/tests/gc/tdisable_orc.nim @@ -0,0 +1,9 @@ +discard """ + joinable: false +""" + +import std/asyncdispatch + +# bug #22256 +GC_disableMarkAndSweep() +waitFor sleepAsync(1000)