From dfa482e292f802edbd172f381293522f8e483d06 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Thu, 13 Mar 2025 00:29:30 +0800 Subject: [PATCH] fixes #24770; Thread local not registed as GC root when =destroy exists (#24776) fixes #24770 e.g. `seq[(ObjectWithDestructors, string)]`/ For refc, a seq with elements that have destructors will have `hasAsgn` flags. The flag is the criteria whether a seq is thought as `containsGarbageCollectedRef`. i.e. whether to `registerTraverseProc` for the type. The culprit seems to be that `searchTypeForAux` doesn't consider the element type of sequence, even it contains a string that should belong to `GarbageCollectedRef`. With this PR: It now generates ``` nimRegisterThreadLocalMarker(TM__mSF73dT1lSI7DG58StKHLQ_5); ``` in refc --- compiler/ccgstmts.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/ccgstmts.nim b/compiler/ccgstmts.nim index ed840a97a8..3aedca9a96 100644 --- a/compiler/ccgstmts.nim +++ b/compiler/ccgstmts.nim @@ -18,7 +18,7 @@ proc registerTraverseProc(p: BProc, v: PSym) = var traverseProc = "" if p.config.selectedGC in {gcMarkAndSweep, gcHooks, gcRefc} and optOwnedRefs notin p.config.globalOptions and - containsGarbageCollectedRef(v.loc.t): + containsManagedMemory(v.loc.t): # we register a specialized marked proc here; this has the advantage # that it works out of the box for thread local storage then :-) traverseProc = genTraverseProcForGlobal(p.module, v, v.info)