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

C "memcpy" shim: ensure the pointers are valid #2968

Merged
merged 2 commits into from
Jul 6, 2023

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Jul 5, 2023

Also add tests for some other shims that already behave correctly

Fixes #2966

Also add tests for some other shims that already behave correctly
@RalfJung
Copy link
Member Author

RalfJung commented Jul 5, 2023

@bors r+

@bors
Copy link
Contributor

bors commented Jul 5, 2023

📌 Commit 2625865 has been approved by RalfJung

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jul 5, 2023

⌛ Testing commit 2625865 with merge b220309...

bors added a commit that referenced this pull request 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
Copy link
Contributor

bors commented Jul 5, 2023

💔 Test failed - checks-actions

@oli-obk
Copy link
Contributor

oli-obk commented Jul 6, 2023

I don't get this CI failure. memrchr exists (it works locally, and it doesn't have any cargo features/cfgs/anything).

@oli-obk
Copy link
Contributor

oli-obk commented Jul 6, 2023

Ooooh, that wasn't clear from the ui_test annotation: this is for a cross compilation target.

@oli-obk
Copy link
Contributor

oli-obk commented Jul 6, 2023

@bors r=RalfJung,oli-obk

@bors
Copy link
Contributor

bors commented Jul 6, 2023

📌 Commit 0613689 has been approved by RalfJung,oli-obk

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jul 6, 2023

⌛ Testing commit 0613689 with merge fc6bd08...

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

Also add tests for some other shims that already behave correctly

Fixes #2966
@RalfJung
Copy link
Member Author

RalfJung commented Jul 6, 2023

Btw, what is this in the test output?

   error file=tests/fail/shims/memrchr_null.stderr,line=0,title=actual output differs from expected::```diff%0A1 unchanged lines skipped%0A-error: Undefined Behavior: memory access failed: null pointer is a dangling pointer (it has no provenance)%0A+error[E0425]: cannot find function `memrchr` in crate `libc`%0A   --> $DIR/memrchr_null.rs:LL:CC%0A    |%0A LL |         libc::memrchr(ptr::null(), 0, 0);%0A-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is a dangling pointer (it has no provenance)%0A+   |               ^^^^^^^%0A    |%0A-   = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior%0A-   = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information%0A-   = note: BACKTRACE:%0A-   = note: inside `main` at $DIR/memrchr_null.rs:LL:CC%0A+  ::: CARGO_REGISTRY/.../mod.rs:LL:CC%0A+   |%0A+LL |     pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void;%0A+   |     -------------------------------------------------------------------- similarly named function `memchr` defined here%0A+   |%0A+help: a function with a similar name exists%0A+   |%0A+LL |         libc::memchr(ptr::null(), 0, 0);%0A+   |               ~~~~~~%0A+help: consider importing this function%0A+   |%0A+LL + use core::slice::memchr::memrchr;%0A+   |%0A+help: if you import `memrchr`, refer to it directly%0A+   |%0A+LL -         libc::memrchr(ptr::null(), 0, 0);%0A+LL +         memrchr(ptr::null(), 0, 0);%0A+   |%0A %0A-note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace%0A-%0A error: aborting due to previous error%0A %0A+For more information about this error, try `rustc --explain E0425`.%0A %0A```

That's a very long line repeating the entire diff... some kind of debug output?

@oli-obk
Copy link
Contributor

oli-obk commented Jul 6, 2023

that's just github actions printing the github actions commands

@@ -1,15 +1,28 @@
error: Undefined Behavior: memory access failed: null pointer is a dangling pointer (it has no provenance)
error[E0425]: cannot find function `memrchr` in crate `libc`
Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like the blessed output now says "cannot find function"? That doesn't seem right?^^

@oli-obk
Copy link
Contributor

oli-obk commented Jul 6, 2023

yea 🤦 I forgot to bless normally again

@bors r=RalfJung,oli-obk

@bors
Copy link
Contributor

bors commented Jul 6, 2023

📌 Commit a9773f5 has been approved by RalfJung,oli-obk

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jul 6, 2023

⌛ Testing commit a9773f5 with merge ee6623f...

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

Also add tests for some other shims that already behave correctly

Fixes #2966
@RalfJung
Copy link
Member Author

RalfJung commented Jul 6, 2023

No need to have that wrong bless in the history at all...

@bors retry r+

@bors
Copy link
Contributor

bors commented Jul 6, 2023

📌 Commit 852d74f has been approved by RalfJung

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jul 6, 2023

⌛ Testing commit 852d74f with merge 8b9be80...

@oli-obk
Copy link
Contributor

oli-obk commented Jul 6, 2023

No need to have that wrong bless in the history at all...

the gh pr checkout command does not allow force pushing 🙃

@bors
Copy link
Contributor

bors commented Jul 6, 2023

☀️ Test successful - checks-actions
Approved by: RalfJung
Pushing 8b9be80 to master...

@bors bors merged commit 8b9be80 into rust-lang:master Jul 6, 2023
@RalfJung RalfJung deleted the memcpy branch July 7, 2023 14:19
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 this pull request may close these issues.

Miri's memcpy shim accepts programs that violate the C spec
3 participants