Hi,
I have a problem with the GC. I am trying to implement a B-Tree like structure and this works fine when I disable the GC, but when enable the GC my tree seems to be GCed away during work and an exception is thrown inside the GC - and I have no idea what's going on - I only use GCed memory in the implementation
this is the basic layout
PNode[T,D] = ref TNode[T,D]
TItem[T,D] = object
key: T
value: D
node: PNode[T,D]
when not (D is string):
val_set: Bool
TNode[T,D] = object
slots: seq[TItem[T,D]]
left: PNode[T,D]
count: Int32
Maybe the traceback helps
Traceback (most recent call last) lazybtree.nim(391) lazybtree gc.nim(430) newObj gc.nim(409) rawNewObj gc.nim(848) collectCT gc.nim(825) collectCTBody gc.nim(777) CollectZCT gc.nim(103) canbeCycleRoot SIGSEGV: Illegal storage access. (Attempt to read from nil?)
TNode[T,D] = object
slots: seq[ref TItem[T,D]]
left: PNode[T,D]
count: Int32
and adjust the implementation accordingly, everything works as expected. It seems the GC has a problem to follow something like:
seq[object]
correctly.
But I don't want the extra redirection (and extra memory consumption) due to
ref TItem