Skip to content

Instantly share code, notes, and snippets.

@jovial
Created August 13, 2014 15:31
Show Gist options
  • Save jovial/588a336c9d2b52992e38 to your computer and use it in GitHub Desktop.
Save jovial/588a336c9d2b52992e38 to your computer and use it in GitHub Desktop.
SIGSEGV with nimrod finializers and echo
type
AObj = object
b : BRef
BObj = object
i : int
ARef = ref AObj
BRef = ref BObj
proc finalize(a : ARef) =
echo "A has gone"
proc finalize(b: BRef) =
echo "B has gone"
for i in 0..500:
var
b : BRef
a : ARef
new(b, finalize)
b.i = 2
new(a,finalize)
a.b = b
assert(a.b.i == 2)
# weird behaviour with echo a.b.i
echo a.b.i
echo "done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment