Skip to content

reset causes crash with cursor and mm:arc #25963

Description

@arnetheduck

Nim Version

2.2.10, 0bfb59f

Description

type Callback = proc() {.closure.}
proc testit(v: ref seq[Callback]) =
  var cbc {.cursor.}: Callback

  proc cb() =
    for c in v[].mitems():
      if c == cbc:
        reset(c)
    reset(cbc) # Commenting this fixes the crash

  cbc = cb

  v[].add cb

proc run() =
  let callbacks = new seq[Callback]
  for i in 0..10:
    testit(callbacks)

  for c in callbacks[]:
    c()

run()

Current Output

/Nim/lib/system/arc.nim(221) nimDestroyAndDispose
/Nim/lib/system/arc.nim(221) nimDestroyAndDispose
/Nim/lib/system/arc.nim(221) nimDestroyAndDispose
/Nim/lib/system/arc.nim nimDecRefIsLast
Error: call depth limit reached in a debug build (2000 function calls). You can change it with -d:nimCallDepthLimit=<int> but really try to avoid deep recursions instead.
Error: execution of an external program failed: 'testit'

Segmentation fault         (core dumped)

Expected Output


Known Workarounds

No response

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions