-
Notifications
You must be signed in to change notification settings - Fork 477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Potential subtle unsafe memory reclaim #237
Conversation
queue_base_block is an experimental queue looks like the queue in crossbeam::channel::unbounded, it maybe better than Michael-Scott lock-free queue in crossbeam::epoch to speed up GC. |
Thanks again for discovering the bug, that is a good catch! :)
Are you thinking about the case where |
Maybe, you means threads blocked by OS's alloc/free operation?
The number is huge. I want to test the stability of this memory-reclaimed.
As time go, at the Actually, I has another more complex approach, but It is also suffer from above question. |
When we guard.defer/defer_destroy(ptr), we must ensure ptr can't be acquire after this moment.
But receivers maybe install the block first, update the 'head' and destroy the old one second, then senders start using old objects(install the next block, but old one has been reclaimed).
Happen to when head_index +1 == tail_index(means avoiding the empty channel), and receivers execute the codes and complete it more quickly:
And now receivers can't acquire the old block, but senders maybe still reference it.
So I improve it through update the 'tail'(If not yet) in 'install_next_block', before defer it.
This is a question that I reasoned about, I didn't try to show it.