bugfix: GC more forgiving

This commit is contained in:
Araq 2011-04-03 22:59:00 +02:00
commit b38c7adad1
5 changed files with 14 additions and 8 deletions

View file

@ -265,7 +265,10 @@ proc unsureAsgnRef(dest: ppointer, src: pointer) {.compilerProc.} =
# reference is in the stack or not (this can happen for var parameters).
if not IsOnStack(dest):
if src != nil: incRef(usrToCell(src))
if dest^ != nil: decRef(usrToCell(dest^))
# XXX finally use assembler for the stack checking instead!
# the test for '!= nil' is correct, but I got tired of the segfaults
# resulting from the crappy stack checking:
if cast[int](dest^) >=% PageSize: decRef(usrToCell(dest^))
dest^ = src
proc initGC() =