<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/library/core/src/sync, branch 1.68.2</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=1.68.2</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=1.68.2'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2023-01-12T07:28:43+00:00</updated>
<entry>
<title>Make `// SAFETY` comment part of the doctest, and not surrounding code</title>
<updated>2023-01-12T07:28:43+00:00</updated>
<author>
<name>Maybe Waffle</name>
<email>waffle.lapkin@gmail.com</email>
</author>
<published>2023-01-12T07:28:43+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=22b4c688956de0925f7a10a79cb0e1ca35f55425'/>
<id>urn:sha1:22b4c688956de0925f7a10a79cb0e1ca35f55425</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Remove unused `mut` from a doctest</title>
<updated>2023-01-12T07:27:51+00:00</updated>
<author>
<name>Maybe Waffle</name>
<email>waffle.lapkin@gmail.com</email>
</author>
<published>2023-01-12T07:27:51+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=f1a63bc2dd5a092ef5384c11f77c8d16d4b9fcc1'/>
<id>urn:sha1:f1a63bc2dd5a092ef5384c11f77c8d16d4b9fcc1</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Add `AtomicPtr::as_mut_ptr`</title>
<updated>2023-01-12T07:27:36+00:00</updated>
<author>
<name>Maybe Waffle</name>
<email>waffle.lapkin@gmail.com</email>
</author>
<published>2023-01-12T07:27:36+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=a513c84a5b54e83b158d0083385864c37cca358c'/>
<id>urn:sha1:a513c84a5b54e83b158d0083385864c37cca358c</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Correct typos in `core::sync::Exclusive::get_{pin_mut, mut}`</title>
<updated>2022-12-12T08:19:17+00:00</updated>
<author>
<name>Albert Larsan</name>
<email>74931857+albertlarsan68@users.noreply.github.com</email>
</author>
<published>2022-12-12T08:19:17+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=736342bb4694b29e96ddc75cc511013780112659'/>
<id>urn:sha1:736342bb4694b29e96ddc75cc511013780112659</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Remove extra spaces</title>
<updated>2022-10-19T22:54:00+00:00</updated>
<author>
<name>clubby789</name>
<email>jamie@hill-daniel.co.uk</email>
</author>
<published>2022-10-19T22:54:00+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=19bc8fb05ab083a315ee4285b4df7822e8bb1e24'/>
<id>urn:sha1:19bc8fb05ab083a315ee4285b4df7822e8bb1e24</id>
<content type='text'>
</content>
</entry>
<entry>
<title>more dupe word typos</title>
<updated>2022-10-14T04:57:56+00:00</updated>
<author>
<name>Rageking8</name>
<email>tomleetyt@gmail.com</email>
</author>
<published>2022-10-13T16:25:34+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=7122abaddf2cf10ce26f86305ff540ae5b38c097'/>
<id>urn:sha1:7122abaddf2cf10ce26f86305ff540ae5b38c097</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Rollup merge of #101774 - Riolku:atomic-update-aba, r=m-ou-se</title>
<updated>2022-10-11T16:59:46+00:00</updated>
<author>
<name>Matthias Krüger</name>
<email>matthias.krueger@famsik.de</email>
</author>
<published>2022-10-11T16:59:46+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=d13f7aef7042dbb37be17b30a2f048dc0ed56f82'/>
<id>urn:sha1:d13f7aef7042dbb37be17b30a2f048dc0ed56f82</id>
<content type='text'>
Warn about safety of `fetch_update`

Specifically as it relates to the ABA problem.

`fetch_update` is a useful function, and one that isn't provided by, say, C++. However, this does not mean the function is magic. It is implemented in terms of `compare_exchange_weak`, and in particular, suffers from the ABA problem. See the following code, which is a naive implementation of `pop` in a lock-free queue:

```rust
fn pop(&amp;self) -&gt; Option&lt;i32&gt; {
    self.front.fetch_update(Ordering::Relaxed, Ordering::Acquire, |front| {
        if front == ptr::null_mut() {
            None
        }
        else {
            Some(unsafe { (*front).next })
        }
    }.ok()
}
```

This code is unsound if called from multiple threads because of the ABA problem. Specifically, suppose nodes are allocated with `Box`. Suppose the following sequence happens:

```
Initial: Queue is X -&gt; Y.

Thread A: Starts popping, is pre-empted.
Thread B: Pops successfully, twice, leaving the queue empty.
Thread C: Pushes, and `Box` returns X (very common for allocators)
Thread A: Wakes up, sees the head is still X, and stores Y as the new head.
```

But `Y` is deallocated. This is undefined behaviour.

Adding a note about this problem to `fetch_update` should hopefully prevent users from being misled, and also, a link to this common problem is, in my opinion, an improvement to our docs on atomics.
</content>
</entry>
<entry>
<title>Add `#[inline]` to trivial functions on `core::sync::Exclusive`</title>
<updated>2022-09-23T05:15:27+00:00</updated>
<author>
<name>Thom Chiovoloni</name>
<email>thom@shift.click</email>
</author>
<published>2022-09-23T05:15:27+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=29efe8c78920e9cd74bb8f7dacff7eaa5370fcf6'/>
<id>urn:sha1:29efe8c78920e9cd74bb8f7dacff7eaa5370fcf6</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Warn about safety of `fetch_update`</title>
<updated>2022-09-14T17:25:14+00:00</updated>
<author>
<name>Keenan Gugeler</name>
<email>me@kgugeler.ca</email>
</author>
<published>2022-09-14T17:25:14+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=3d28a1ad761f4106e62e90ceebb209af533a1f24'/>
<id>urn:sha1:3d28a1ad761f4106e62e90ceebb209af533a1f24</id>
<content type='text'>
Specifically as it relates to the ABA problem.
</content>
</entry>
<entry>
<title>fix nitpicks from review</title>
<updated>2022-08-21T02:36:11+00:00</updated>
<author>
<name>Maybe Waffle</name>
<email>waffle.lapkin@gmail.com</email>
</author>
<published>2022-08-21T02:36:11+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=b2625e24b95b5077a1ec59ad6ac667939eb6521f'/>
<id>urn:sha1:b2625e24b95b5077a1ec59ad6ac667939eb6521f</id>
<content type='text'>
</content>
</entry>
</feed>
