Skip to content
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

Use pointer type in AtomicPtr::swap implementation #80236

Merged
merged 1 commit into from
Dec 21, 2020

Conversation

tmiasko
Copy link
Contributor

@tmiasko tmiasko commented Dec 20, 2020

Closes #80234.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 20, 2020
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-9 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling hashbrown v0.9.0
   Compiling object v0.22.0
   Compiling miniz_oxide v0.4.0
   Compiling addr2line v0.14.0
error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `*mut ()`
     |
     |
2417 |             SeqCst => intrinsics::atomic_xchg(dst, val),


error[E0511]: invalid monomorphization of `atomic_xchg_acqrel` intrinsic: expected basic integer type, found `*mut ()`
     |
     |
2415 |             AcqRel => intrinsics::atomic_xchg_acqrel(dst, val),


error[E0511]: invalid monomorphization of `atomic_xchg_acq` intrinsic: expected basic integer type, found `*mut ()`
     |
     |
2413 |             Acquire => intrinsics::atomic_xchg_acq(dst, val),


error[E0511]: invalid monomorphization of `atomic_xchg_rel` intrinsic: expected basic integer type, found `*mut ()`
     |
     |
2414 |             Release => intrinsics::atomic_xchg_rel(dst, val),


error[E0511]: invalid monomorphization of `atomic_xchg_relaxed` intrinsic: expected basic integer type, found `*mut ()`
     |
     |
2416 |             Relaxed => intrinsics::atomic_xchg_relaxed(dst, val),

error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0511`.

@tmiasko

This comment has been minimized.

if int_type_width_signed(ty, bx.tcx()).is_some() {
bx.atomic_rmw(atom_op, args[0].immediate(), args[1].immediate(), order)
if int_type_width_signed(ty, bx.tcx()).is_some()
|| (ty.is_unsafe_ptr() && op == "xchg")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels a bit piecemeal to do this just for one operation. Won't we simply be back at this soon with another operation?

If you have the time, could you remove all as *mut usize and as usize from the implementation of AtomicPtr and adjust the intrinsics accordingly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is anything left (though I might have missed something). Remaining operations are intentionally unsupported in atomic ptr, so I don't think we should support them in intrinsics either.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, great, thanks for having a look!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this was not quite right (or the situation changed since then)

Copy link
Contributor Author

@tmiasko tmiasko Mar 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no pointer to integer casts in AtomicPtr implementation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, you are right... need to follow up in that issue then.

@oli-obk
Copy link
Contributor

oli-obk commented Dec 20, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Dec 20, 2020

📌 Commit 4ad53dc has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 20, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Dec 21, 2020
Use pointer type in AtomicPtr::swap implementation

Closes rust-lang#80234.
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 21, 2020
Rollup of 11 pull requests

Successful merges:

 - rust-lang#80159 (Add array search aliases)
 - rust-lang#80166 (Edit rustc_middle docs)
 - rust-lang#80170 (Fix ICE when lookup method in trait for type that have bound vars)
 - rust-lang#80171 (Edit rustc_middle::ty::TyKind docs)
 - rust-lang#80199 (also const-check FakeRead)
 - rust-lang#80211 (Handle desugaring in impl trait bound suggestion)
 - rust-lang#80236 (Use pointer type in AtomicPtr::swap implementation)
 - rust-lang#80239 (Update Clippy)
 - rust-lang#80240 (make sure installer only creates directories in DESTDIR)
 - rust-lang#80244 (Cleanup markdown span handling)
 - rust-lang#80250 (Minor cleanups in LateResolver)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 328e89c into rust-lang:master Dec 21, 2020
@rustbot rustbot added this to the 1.50.0 milestone Dec 21, 2020
@tmiasko tmiasko deleted the atomic-swap branch December 21, 2020 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Miri detects MPSC as having UB according to stacked borrows
7 participants