loony icon indicating copy to clipboard operation
loony copied to clipboard

[ORC] Crash when GC attempts to collect element

Open shayanhabibi opened this issue 4 years ago • 4 comments

Orc crashes when a Continuation (or any ref object) passed through the queue reaches the end of its life span and the final =destroy is run.

This is evident by incrementing the ref count of an object by 1 before the end of its lifespan and comparing the behaviour before and after.

ARC does not share this issue; the final =destroy can be called without issue and the memory is collected appropriately.

shayanhabibi avatar Sep 18 '21 01:09 shayanhabibi

AFAIK this is a ORC bug

shayanhabibi avatar Sep 18 '21 01:09 shayanhabibi

What would need to be done to make a ref reach the end of its lifetime? Like what would a small example look like?

PhilippMDoerner avatar Jan 01 '24 22:01 PhilippMDoerner

block:
  var x = new (ref int)
  x[] = 3
# x reached the end of its lifetime

disruptek avatar Jan 02 '24 15:01 disruptek

To restate the problem, the issue is that Nim's ORC tracking of each memory graph is thread-local, so moves across threads leave such references in a bogus state should they be collected in a "foreign" thread...

disruptek avatar Jan 02 '24 15:01 disruptek