nim-works / loony

A high throughput MPMC lock-free queue based on a paper by Giersch, Nolte et al implemented in pure Nim.
https://nim-works.github.io/loony/
MIT License
65 stars 4 forks source link

[ORC] Crash when GC attempts to collect element #4

Open shayanhabibi opened 3 years ago

shayanhabibi commented 3 years ago

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 commented 3 years ago

AFAIK this is a ORC bug

PhilippMDoerner commented 9 months ago

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

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

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...