nim-works / loony

A high throughput MPMC lock-free queue based on a paper by Giersch, Nolte et al implemented in pure Nim.

Home Page:https://nim-works.github.io/loony/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[NIM] Thread completion triggers thread sanitizer warnings

shayanhabibi opened this issue · comments

Thread analyzer determines the deallocshared proc called by a thread on completion is a data-race.

Atm only solution I can come up with involves changing or providing a modified std lib thread library that corrects this behaviour. The safest methodology is having the pointer deallocshared acts on being atomically stored and loaded for destruction? Haven't look too deep into it yet.

Related to #9 and #13

I now see the problem is definitely more convoluted and it is not isolated to just the thread deallocation. Numerous other issues are raised despite our own safe understanding of the order of operations with deallocations in loony. For now I think more involved tests that actually have work and require memory coherance to arrive at correct computations is required.

Nim's allocator is buggy and --define:useMalloc is the only realistic way forward.