Repository navigation
Conversation
|
I don't like there being an ignored load here but 🤷🏻 |
| this.inner().weak.store(1, Release); // release the lock | ||
| unique | ||
| } else { | ||
| let _ = this.inner().strong.load(Acquire); |
There was a problem hiding this comment.
Is this strictly necessary? As in, does it really matter what the strong count is if the weak count says that it's not unique anyway, and you'd need to re-check the weak count to verify this?
There was a problem hiding this comment.
we need an acquire fence of some kind that touches strong. otherwise e.g. increment_strong_count won't properly synchronise as promised and that's observable (it ends up calling clone which only does a relaxed op so..)
There was a problem hiding this comment.
Ugh, that's annoying, but I guess you're right. We do explicitly state this in the docs, even though I'm not sure we should.
There was a problem hiding this comment.
loosening the guarantee is also an option. i believe @SabrinaJewson originally introduced this and might be able to give more context on the desired semantics?
There was a problem hiding this comment.
I have a feeling that modifying the strong and weak counts was not something said with a whole lot of thought, but maybe it was. To me, the important aspect is that is_unique can explicitly be ordered before get_mut_unchecked, and so the strong count doesn't necessarily have to be involved in the false case, because in the false case you can't actually do that.
There was a problem hiding this comment.
My intent with the comment was just about get_mut_unchecked, so I was thinking that it would only Acquire when it returns true, but this must have slipped my mind when actually writing it. My bad 😦
If it’s not considered too much of a breaking change, I would be in favour of weakening the guarantee. If you find out an Arc is not unique, what is there to acquire anyway?
There was a problem hiding this comment.
no worries, wfm ^^ I'll check in with the team to be safe but I'll change this to a doc pr
|
I don't understand why we can't just remove the guarantee here. AFAIK, ordering of the atomic operations on Does this have perf implications? |
|
it was an explicit request by the team (rust-lang/libs-team#560 (comment)). worth checking that meeting's notes and/or cc @joshtriplett in case you remember but either way it makes sense that you'd want to guarantee this ordering in most cases to ensure it's safe to do a |
|
If it's not safe to |
|
We can decide at the meeting what to do with this. I think what might make the most sense is to revert the stabilization of |
| this.inner().weak.store(1, Release); // release the lock | ||
| unique | ||
| } else { | ||
| let _ = this.inner().strong.load(Acquire); |
There was a problem hiding this comment.
This desperately needs a comment.
|
Closing in favour of #166400 which was decided upon during the meeting. |
… r=hanna-kruppe
Revert "stabilize {Arc,Rc}::is_unique"
Supercedes rust-lang#165962.
Reopens rust-lang#138938.
As mentioned last week: https://github.com/rust-lang/libs-team/blob/56dd8ca2e2aa2c097d8b8010da6fef790a5ec97c/minutes/2026-11-17.md#165962-arc-make-is_unique-respect-promised-ordering
(Note: this only reverts the stabilization commit, not the docs changes from the original PR. Those can stay.)
… r=hanna-kruppe
Revert "stabilize {Arc,Rc}::is_unique"
Supercedes rust-lang#165962.
Reopens rust-lang#138938.
As mentioned last week: https://github.com/rust-lang/libs-team/blob/56dd8ca2e2aa2c097d8b8010da6fef790a5ec97c/minutes/2026-11-17.md#165962-arc-make-is_unique-respect-promised-ordering
(Note: this only reverts the stabilization commit, not the docs changes from the original PR. Those can stay.)
… r=hanna-kruppe
Revert "stabilize {Arc,Rc}::is_unique"
Supercedes rust-lang#165962.
Reopens rust-lang#138938.
As mentioned last week: https://github.com/rust-lang/libs-team/blob/56dd8ca2e2aa2c097d8b8010da6fef790a5ec97c/minutes/2026-11-17.md#165962-arc-make-is_unique-respect-promised-ordering
(Note: this only reverts the stabilization commit, not the docs changes from the original PR. Those can stay.)
… r=hanna-kruppe
Revert "stabilize {Arc,Rc}::is_unique"
Supercedes rust-lang#165962.
Reopens rust-lang#138938.
As mentioned last week: https://github.com/rust-lang/libs-team/blob/56dd8ca2e2aa2c097d8b8010da6fef790a5ec97c/minutes/2026-11-17.md#165962-arc-make-is_unique-respect-promised-ordering
(Note: this only reverts the stabilization commit, not the docs changes from the original PR. Those can stay.)
…uppe
Revert "stabilize {Arc,Rc}::is_unique"
Supercedes #165962.
Reopens #138938.
As mentioned last week: https://github.com/rust-lang/libs-team/blob/56dd8ca2e2aa2c097d8b8010da6fef790a5ec97c/minutes/2026-11-17.md#165962-arc-make-is_unique-respect-promised-ordering
(Note: this only reverts the stabilization commit, not the docs changes from the original PR. Those can stay.)
the docs on
Arc::is_uniqueimply thatAcquireloads are performed irrespective of success, but that's not how we handle this now and unsafe code can trigger UB because of this discrepancy. we could alternatively weaken the guarantee, but that would need to be somewhat hasty since this will be stable in 1.101. libs-nominated to decide what to do here.thank you to @obi1kenobi & OpenAI for finding and reporting this!
AI-generated repro (that fails without acquire ordering)
With the Miri component for
nightly-2026-11-07, run the seed-zero case.r? libs