rust/src/tools
Matthias Krüger 5e4eab454a
Rollup merge of #128778 - RalfJung:atomic-read-read-races, r=Mark-Simulacrum
atomics: allow atomic and non-atomic reads to race

We currently define our atomics in terms of C++ `atomic_ref`. That has the unfortunate side-effect of making it UB for an atomic and a non-atomic read to race (concretely, [this code](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d1a743774e60923db33def7fe314d754) has UB). There's really no good reason for this, all the academic models of the C++ memory model I am aware of allow this -- C++ just disallows this because of their insistence on an "object model" with typed memory, where `atomic_ref` temporarily creates an "atomic object" that may not be accesses via regular non-atomic operations.

So instead of tying our operations to `atomic_ref`, let us tie them directly to the underlying C++ memory model. I am not sure what is the best way to phrase this, so here's a first attempt.

We also carve out an exception from the "no mixed-size atomic accesses" rule to permit mixed-size atomic reads -- given that we permit mixed-size non-atomic reads, it seems odd that this would be disallowed for atomic reads. However, when an atomic write races with any other atomic operation, they must use the same size.

With this change, it is finally the case that every non-atomic access can be replaced by an atomic access without introducing UB.

Cc `@rust-lang/opsem` `@chorman0773` `@m-ou-se` `@WaffleLapkin` `@Amanieu`

Fixes https://github.com/rust-lang/unsafe-code-guidelines/issues/483
2024-09-28 15:11:21 +02:00
..
build-manifest Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
build_helper Auto merge of #130121 - lolbinarycat:bootstrap-warn-old-upstream-worktree, r=albertlarsan68 2024-09-13 22:02:35 +00:00
bump-stage0 Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
cargo@80d82ca22a Update cargo 2024-09-27 15:45:11 -04:00
cargotest Reformat use declarations. 2024-07-29 08:26:52 +10:00
clippy Rollup merge of #130912 - estebank:point-at-arg-type, r=compiler-errors 2024-09-26 22:20:57 -07:00
collect-license-metadata Update generate-copyright 2024-08-06 11:04:55 +01:00
compiletest bump few deps 2024-09-27 09:23:05 +03:00
coverage-dump Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
enzyme@2fe5164a24 Enzyme backend 2024-09-05 22:47:23 -04:00
error_index_generator Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
generate-copyright Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
generate-windows-sys Add windows-targets crate to std's sysroot 2024-08-09 10:43:43 +00:00
html-checker rustdoc: redesign toolbar and disclosure widgets 2024-09-10 17:56:05 -07:00
jsondocck Reformat use declarations. 2024-07-29 08:26:52 +10:00
jsondoclint Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
libcxx-version skip src/tools/libcxx-version from tidy 2024-06-06 07:01:37 +03:00
linkchecker update the doc comment on lintchecker b/c it parses html now 2024-08-24 12:35:35 -04:00
lint-docs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
lld-wrapper Reformat use declarations. 2024-07-29 08:26:52 +10:00
llvm-bitcode-linker Reformat use declarations. 2024-07-29 08:26:52 +10:00
miri Further clarificarion for atomic and UnsafeCell docs: 2024-09-28 12:14:59 +02:00
miropt-test-tools
opt-dist Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
remote-test-client Reformat use declarations. 2024-07-29 08:26:52 +10:00
remote-test-server Reformat use declarations. 2024-07-29 08:26:52 +10:00
replace-version-placeholder Reformat use declarations. 2024-07-29 08:26:52 +10:00
rls Reformat use declarations. 2024-07-29 08:26:52 +10:00
run-make-support Fix run-make-support to respect per-stage cargo 2024-09-24 19:04:51 +08:00
rust-analyzer Add missing rustc_private 2024-09-25 10:56:37 +03:00
rust-installer Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
rustbook cargo update: rustbook 2024-09-26 12:56:46 -04:00
rustc-perf@d5055e7804 bump up rustc-perf's version 2024-08-09 01:24:39 +09:00
rustc-perf-wrapper impl compare command and benchmark command to rustc-perf-wrapper 2024-08-09 20:03:14 +09:00
rustdoc Link std statically in rustc_driver 2024-08-11 04:16:53 +02:00
rustdoc-gui Other EcmaScript version bump 2024-06-07 08:44:52 +08:00
rustdoc-gui-test Reformat use declarations. 2024-07-29 08:26:52 +10:00
rustdoc-js Separate core search logic with search ui 2024-08-29 00:26:16 +08:00
rustdoc-themes Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
rustfmt Merge commit 'b23b69900e' into sync-from-rustfmt 2024-09-19 21:46:44 -04:00
suggest-tests Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
tidy Auto merge of #130964 - matthiaskrgr:rollup-suriuub, r=matthiaskrgr 2024-09-28 10:46:56 +00:00
tier-check Add NuttX based targets for RISC-V and ARM 2024-07-19 22:00:42 +08:00
unicode-table-generator Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
unstable-book-gen Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
wasm-component-ld Fix a typo in the wasm-component-ld README 2024-09-06 09:20:53 -07:00
x Reformat use declarations. 2024-07-29 08:26:52 +10:00
cherry-pick.sh
publish_toolstate.py