SIGSEGV in GC_fullCollect for ORC
### Description

The following code raises `SIGSEGV: Illegal storage access. (Attempt to read from nil?)` when it is compiled and executed (`nim c -r test.nim `).

```nim
type
  HasGid = ref object of RootRef
    gid: uint = 0u

  # Slot = ref object               #*** Variation 1
  # Slot = ref object of RootRef    #*** Variation 2
  Slot = ref object of HasGid
    receiver {.cursor.}: Receiver
    f: proc()
    # f: proc() {.nimcall.}         #*** Variation 3 (a)

  Signal* = ref object of HasGid
    slots: seq[Slot]

  Receiver* = ref object of HasGid
    # Note that the Receiver's gid value gets initialized in newSlot)
    signals*: seq[Signal]    # Note that this is a seq of *cursor*'s

proc initGid(x: HasGid) =
  if x.gid == 0u:
    x.gid = cast[uint](x.gid.addr)

# Used by destructor to find an object in a seq of refs
proc `==` * (x:HasGid; y: typeof(HasGid()[])): bool =
  x.gid == y.gid

proc `=destroy`(x:typeof(Receiver()[])) # Fwd decl to avoid compile error

proc `=destroy`(x:typeof(Signal()[])) =
  echo "`=destroy` for Signal"
  # Remove all references pointing to this object from Receiver objects
  for slot in x.slots:
    let rx = slot.receiver
    if (let idx = rx.signals.find(x); idx != -1):
      rx.signals.del(idx)
  `=destroy`(x.slots)

proc `=destroy`(x:typeof(Receiver()[])) =
  echo "`=destroy` for Receiver"
  # Remove all references pointing to this object from Signal objects
  for sig in x.signals:
    var idx = 0
    let endslt = sig.slots.len - 1
    for i in 0 .. endslt:
      let rx = sig.slots[idx].receiver
      if rx.gid == x.gid:
        sig.slots.del(idx)
      else:
        inc idx
  `=destroy`(x.signals)

# proc newSlot(rcvr: Receiver, fn: proc() {.nimcall.}): Slot =  #*** Variation 3 (b)
proc newSlot(rcvr: Receiver, fn: proc()): Slot =
  rcvr.initGid()
  result = Slot(receiver: rcvr, f: fn)
  # result.initGid()  # Has no effect on the  problem

proc newSignal*() : Signal =
  result = Signal.new()
  result.slots.newSeq 0
  result.initGid()

proc connect*(
      sig: Signal; 
      rcvr: Receiver; 
      # f: proc() {.nimcall.}) =          #*** Variation 3 (c)
      f: proc()) =
  # Use cursor's to avoid the possibility of introducing a reference cycle
  let sigx {.cursor.} = sig
  let rcvrx {.cursor.} = rcvr
  sig.slots.add newSlot(rcvrx, f)
  rcvr.signals.add sigx

#==============================================================

block:
  echo "\nBlock 1"

  proc cb1() =
    echo "Entered cb1"

  let src1 = newSignal()

  let dst1 = new(Receiver)
  dst1.signals.newSeq 0

  echo "Call connect"
  src1.connect(dst1, cb1)         #*** Variation 4 (a)

  echo "Leave Block 1"

block:
  echo "\nBlock 2"

  proc cb1x() =
    echo "Entered cb1x"

  let src1x = newSignal()

  let dst1x = new(Receiver)
  dst1x.signals.newSeq 0

  echo "Call connect"
  src1x.connect(dst1x, cb1x)       #*** Variation 4 (b)

  echo "Leave Block 2"

echo "\nCall GC_fullCollect"
GC_fullCollect()
```


### Nim Version

Nim Compiler Version 2.2.0 [Linux: amd64]
Compiled at 2024-10-02
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: 78983f1876726a49c69d65629ab433ea1310ece1
active boot switches: -d:release


### Current Output

```text
Block 1
Call connect
Leave Block 1
`=destroy` for Receiver
`=destroy` for Signal

Block 2
Call connect
Leave Block 2
`=destroy` for Receiver
`=destroy` for Signal

Call GC_fullCollect
Traceback (most recent call last)
xxx/test.nim(109) test
/opt/nim-2.2.0/lib/system/orc.nim(479) GC_fullCollect
/opt/nim-2.2.0/lib/system/orc.nim(407) collectCycles
/opt/nim-2.2.0/lib/system/orc.nim(334) collectCyclesBacon
/opt/nim-2.2.0/lib/system/orc.nim(211) markGray
/opt/nim-2.2.0/lib/system/orc.nim(80) trace
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
```


### Expected Output

```text
Block 1
Call connect
Leave Block 1
`=destroy` for Receiver
`=destroy` for Signal

Block 2
Call connect
Leave Block 2
`=destroy` for Receiver
`=destroy` for Signal

Call GC_fullCollect
```


### Known Workarounds

For reasons that are unknown to me, the error does not occur if any one of the following changes is made to the above code:
* Change the declaration of `Slot` from `ref object of HasGid` to `ref object` (Variation 1)
* Change the declaration of `Slot` from `ref object of HasGid` to `ref object of RootRef` (Variation 2)
* Change the `f: proc()` field in `Slot` to be `{.nimcall.}` (Variation 3 a, b and c)
* Comment out the call to `connect` in either Block1 or Block2 (Variation 4 a or b)


### Additional Information

_No response_