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

Miri's memcpy shim accepts programs that violate the C spec #2966

Closed
RalfJung opened this issue Jul 4, 2023 · 0 comments · Fixed by #2968
Closed

Miri's memcpy shim accepts programs that violate the C spec #2966

RalfJung opened this issue Jul 4, 2023 · 0 comments · Fixed by #2968

Comments

@RalfJung
Copy link
Member

RalfJung commented Jul 4, 2023

Miri implements memcpy as basically an alias of copy_nonoverlapping. That's not correct though: according to the C spec, memcpy is UB when the pointer is null or dangling, even if the copy is for 0 bytes. We should fix our shim.

bors added a commit that referenced this issue Jul 5, 2023
C "memcpy" shim: ensure the pointers are valid

Also add tests for some other shims that already behave correctly

Fixes #2966
bors added a commit that referenced this issue Jul 6, 2023
C "memcpy" shim: ensure the pointers are valid

Also add tests for some other shims that already behave correctly

Fixes #2966
bors added a commit that referenced this issue Jul 6, 2023
C "memcpy" shim: ensure the pointers are valid

Also add tests for some other shims that already behave correctly

Fixes #2966
@bors bors closed this as completed in 8b9be80 Jul 6, 2023
RalfJung pushed a commit to RalfJung/rust that referenced this issue Jul 8, 2023
C "memcpy" shim: ensure the pointers are valid

Also add tests for some other shims that already behave correctly

Fixes rust-lang/miri#2966
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant