-
Notifications
You must be signed in to change notification settings - Fork 389
FnAbi Compatability check #4185
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//@ignore-target: windows # File handling is not implemented yet | ||
//@compile-flags: -Zmiri-disable-isolation | ||
use std::ffi::{CString, OsStr, c_char, c_int}; | ||
use std::os::unix::ffi::OsStrExt; | ||
|
||
extern "C" { | ||
fn open(path: *const c_char, oflag: c_int, ...) -> c_int; | ||
// correct fd type is i32 | ||
fn close(fd: u32) -> c_int; | ||
} | ||
|
||
fn main() { | ||
let c_path = CString::new(OsStr::new("./text").as_bytes()).expect("CString::new failed"); | ||
let fd = unsafe { | ||
open(c_path.as_ptr(), /* value does not matter */ 0) | ||
} as u32; | ||
let _ = unsafe { | ||
close(fd); | ||
//~^ ERROR: calling a function with argument of type i32 passing data of type u32 | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error: Undefined Behavior: calling a function with argument of type i32 passing data of type u32 | ||
--> tests/fail/shims/input_arg_mismatch.rs:LL:CC | ||
| | ||
LL | close(fd); | ||
| ^^^^^^^^^ calling a function with argument of type i32 passing data of type u32 | ||
| | ||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior | ||
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information | ||
= help: this means these two types are not *guaranteed* to be ABI-compatible across all targets | ||
= help: if you think this code should be accepted anyway, please report an issue with Miri | ||
= note: BACKTRACE: | ||
= note: inside `main` at tests/fail/shims/input_arg_mismatch.rs:LL:CC | ||
|
||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace | ||
|
||
error: aborting due to 1 previous error | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//@ignore-target: windows # File handling is not implemented yet | ||
//@compile-flags: -Zmiri-disable-isolation | ||
use std::ffi::{CString, OsStr, c_char, c_int, c_short}; | ||
use std::os::unix::ffi::OsStrExt; | ||
|
||
extern "C" { | ||
fn open(path: *const c_char, oflag: c_int, ...) -> c_int; | ||
// correct return type is i32 | ||
fn close(fd: c_int) -> c_short; | ||
} | ||
|
||
fn main() { | ||
let c_path = CString::new(OsStr::new("./text").as_bytes()).expect("CString::new failed"); | ||
let fd = unsafe { | ||
open(c_path.as_ptr(), /* value does not matter */ 0) | ||
}; | ||
let _ = unsafe { | ||
close(fd); | ||
//~^ ERROR: calling a function with return type i32 passing return place of type i16 | ||
}; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error: Undefined Behavior: calling a function with return type i32 passing return place of type i16 | ||
--> tests/fail/shims/return_type_mismatch.rs:LL:CC | ||
| | ||
LL | close(fd); | ||
| ^^^^^^^^^ calling a function with return type i32 passing return place of type i16 | ||
| | ||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior | ||
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information | ||
= help: this means these two types are not *guaranteed* to be ABI-compatible across all targets | ||
= help: if you think this code should be accepted anyway, please report an issue with Miri | ||
= note: BACKTRACE: | ||
= note: inside `main` at tests/fail/shims/return_type_mismatch.rs:LL:CC | ||
|
||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace | ||
|
||
error: aborting due to 1 previous error | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.