Skip to content

Conversation

@samrat
Copy link
Contributor

@samrat samrat commented Apr 26, 2020

Issue: rust-lang/miri#1355

If an extern C function is defined as

extern "C" {
    fn malloc(size: u32) -> *mut std::ffi::c_void;
}

on a 64-bit machine(ie. pointer sizes don't match), return undefined behaviour from Miri when converting the argument into machine_usize

If an extern C function is defined as

```
extern "C" {
    fn malloc(size: u32) -> *mut std::ffi::c_void;
}
```

on a 64-bit machine(ie. pointer sizes don't match), throw an undefined
behaviour.
@rust-highfive
Copy link
Contributor

r? @petrochenkov

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 26, 2020
@petrochenkov
Copy link
Contributor

r? @RalfJung

@RalfJung
Copy link
Member

@samrat thanks a lot, this looks great! I just have some minor nits.

@samrat samrat force-pushed the miri-ub-on-size-mismatch branch from 0acd3eb to b8af409 Compare April 26, 2020 14:44
@RalfJung
Copy link
Member

I adjusted style a bit more as I had missed that before. Thanks!

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Apr 26, 2020

📌 Commit c8d8c42 has been approved by RalfJung

@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 Apr 26, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 26, 2020
Rollup of 5 pull requests

Successful merges:

 - rust-lang#71421 (Add a function to turn Box<T> into Box<[T]>)
 - rust-lang#71537 (Remove support for self-opening)
 - rust-lang#71551 (Minor refactoring around IndexVec usage in generator transformation)
 - rust-lang#71569 ([miri] Throw UB if target size and data size don't match)
 - rust-lang#71576 (check that `AsRef` and `AsMut` are inlined)

Failed merges:

 - rust-lang#71558 (Cleanup and document `-Z tls-model` )

r? @ghost
@bors bors merged commit b2a8a8a into rust-lang:master Apr 26, 2020
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.

5 participants