diff options
author | Jaremy Creechley <creechley@gmail.com> | 2024-03-25 11:59:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-25 10:59:18 +0100 |
commit | 280f877145dffbf74e28605ab3d0dd9afdb1c5b2 (patch) | |
tree | 10347d7818713b2a149eb98e890e2efebecd5ce8 | |
parent | 33902d9dbb65fbfdfbd6e3b2a34c6e19eccb762f (diff) | |
download | Nim-280f877145dffbf74e28605ab3d0dd9afdb1c5b2.tar.gz |
fix atomicarc increment (#23427)
The fix to the atomicArc looks to use `-1` as the check value from the `SharedPtr` solution. However, it should be `-rcIncrement` since the refcount is bit shifted in ARC/ORC. I discovered this playing around doing atomic updates of refcounts in a user library. Related to https://github.com/nim-lang/Nim/issues/22711 @ringabout I believe you ported the sharedptr fix?
-rw-r--r-- | lib/system/arc.nim | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/system/arc.nim b/lib/system/arc.nim index 99c892676..d001fcaa5 100644 --- a/lib/system/arc.nim +++ b/lib/system/arc.nim @@ -221,7 +221,7 @@ proc nimDecRefIsLast(p: pointer): bool {.compilerRtl, inl.} = when defined(gcAtomicArc) and hasThreadSupport: # `atomicDec` returns the new value - if atomicDec(cell.rc, rcIncrement) == -1: + if atomicDec(cell.rc, rcIncrement) == -rcIncrement: result = true when traceCollector: cprintf("[ABOUT TO DESTROY] %p\n", cell) |