-
Notifications
You must be signed in to change notification settings - Fork 459
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
Reclaim inactive participant data #70
Conversation
Lurr, the |
Yeah, I think that this can leave Then thread B exits. So T1 unlinks it from But |
…ng the low order bits of the pointer
…inked list removal algorithm. Fixes crossbeam-rs#37.
561888b
to
7f45314
Compare
Right - just because I found one bug doesn't mean there aren't others. I completely scrapped the old code and used essentially Tim Harris's linked list removal algorithm instead. This involved introducing a new |
Oddly, though, the slammer script, even after running for at least 16 hours on my original attempt (which, as you pointed out, was still buggy), never reported a crash. |
This seems plausible to me. Am I right in thinking that the Maybe we need a test script that more heavily stresses thread creation/destruction to make these bugs more visible. |
Is there anything specific blocking this? Otherwise it's a great fix. |
Hey! It appears that this already adds the functionality I proposed in #102. It also has support for more things, notably arbitrarily sized markers and |
I... completely forgot about this PR. As far as I know, there isn't anything really blocking this. @msullivan I believe that it is just an optimization, but I think I'd prefer to just stick as close to Tim Harris's described algorithm as possible. @Vtec234 That sounds reasonable to me. |
…ypes not aligned to powers of 2
Additions to markable atomic type
Thanks to @Vtec234, I think the |
Ping. It'd be nice to have #37 fixed. |
FYI, https://internals.rust-lang.org/t/crossbeam-request-for-help/4933 -- I'm actively looking to hand over maintenance, as I simply do not have the time to give this library attention. |
@arthurprs @gereeter @msullivan in particular I'd love to bring any of you on as maintainers, if you're game. |
Hi! I just wonder if we could merge We can simply name it |
EDIT: On second thought, I am not sure this is a good idea. Notice that e.g. |
Is it a good idea? I'm not sure all methods interact well across tag/normal use. |
The code that was removed in #42 was almost correct - it removed inactive participants from the list and tried to guard against multiple treads removing the same node. However, it guarded for that in an exactly backwards way:unlinked
needs to be called by the first thread to remove the node, and so should run if thecompare_and_swap
succeeded. However, sincecompare_and_swap
returns the previous value, it succeeds iff it returnsfalse
, nottrue
. Thus, nodes were only unlinked by threads that weren't alone in removing the same participant. This also explains why the bug was so hard to exhibit - to get a double free, three threads had to simultaneously remove the same node.I tested this with the slammer script posted in #42 - while the buggy code would segfault quickly (within a minute), I left the slammer running with this patched applied for over half an hour and it never failed.This is implemented using a variation on Tim Harris's linked list removal algorithm.
Fixes #37.