-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Enable Miri to pass pointers through FFI #129684
Conversation
Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri The Miri subtree was changed cc @rust-lang/miri |
Oh. Well that didn't work yet. |
@@ -1 +1,2 @@ | |||
printing from C | |||
printing pointer dereference from C: 42 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
This comment has been minimized.
This comment has been minimized.
(I might quickly try to enhance+refactor the C pointer FFI tests in Miri now.) |
dcdb101
to
6e23a4d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, thanks! Just got some nits regarding the tests.
Please squash the commits, then we can land this. :-) |
Co-authored-by: Ralf Jung <[email protected]>
730bd97
to
7fde02e
Compare
Great, congrats on getting this finished! @bors r+ |
… r=RalfJung Enable Miri to pass pointers through FFI Following rust-lang#126787, the purpose of this PR is to now enable Miri to execute native calls that make use of pointers. > <details> > > <summary> Simple example </summary> > > ```rust > extern "C" { > fn ptr_printer(ptr: *mut i32); > } > > fn main() { > let ptr = &mut 42 as *mut i32; > unsafe { > ptr_printer(ptr); > } > } > ``` > ```c > void ptr_printer(int *ptr) { > printf("printing pointer dereference from C: %d\n", *ptr); > } > ``` > should now show `printing pointer dereference from C: 42`. > > </details> Note that this PR does not yet implement any logic involved in updating Miri's "analysis" state (byte initialization, provenance) upon such a native call. r? `@RalfJung`
…iaskrgr Rollup of 11 pull requests Successful merges: - rust-lang#128523 (Add release notes for 1.81.0) - rust-lang#129605 (Add missing `needs-llvm-components` directives for run-make tests that need target-specific codegen) - rust-lang#129650 (Clean up `library/profiler_builtins/build.rs`) - rust-lang#129651 (skip stage 0 target check if `BOOTSTRAP_SKIP_TARGET_SANITY` is set) - rust-lang#129684 (Enable Miri to pass pointers through FFI) - rust-lang#129762 (Update the `wasm-component-ld` binary dependency) - rust-lang#129782 (couple more crash tests) - rust-lang#129816 (tidy: say which feature gate has a stability issue mismatch) - rust-lang#129818 (make the const-unstable-in-stable error more clear) - rust-lang#129824 (Fix code examples buttons not appearing on click on mobile) - rust-lang#129826 (library: Fix typo in `core::mem`) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 11 pull requests Successful merges: - rust-lang#128523 (Add release notes for 1.81.0) - rust-lang#129605 (Add missing `needs-llvm-components` directives for run-make tests that need target-specific codegen) - rust-lang#129650 (Clean up `library/profiler_builtins/build.rs`) - rust-lang#129651 (skip stage 0 target check if `BOOTSTRAP_SKIP_TARGET_SANITY` is set) - rust-lang#129684 (Enable Miri to pass pointers through FFI) - rust-lang#129762 (Update the `wasm-component-ld` binary dependency) - rust-lang#129782 (couple more crash tests) - rust-lang#129816 (tidy: say which feature gate has a stability issue mismatch) - rust-lang#129818 (make the const-unstable-in-stable error more clear) - rust-lang#129824 (Fix code examples buttons not appearing on click on mobile) - rust-lang#129826 (library: Fix typo in `core::mem`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#129684 - Strophox:miri-pass-pointer-to-ffi, r=RalfJung Enable Miri to pass pointers through FFI Following rust-lang#126787, the purpose of this PR is to now enable Miri to execute native calls that make use of pointers. > <details> > > <summary> Simple example </summary> > > ```rust > extern "C" { > fn ptr_printer(ptr: *mut i32); > } > > fn main() { > let ptr = &mut 42 as *mut i32; > unsafe { > ptr_printer(ptr); > } > } > ``` > ```c > void ptr_printer(int *ptr) { > printf("printing pointer dereference from C: %d\n", *ptr); > } > ``` > should now show `printing pointer dereference from C: 42`. > > </details> Note that this PR does not yet implement any logic involved in updating Miri's "analysis" state (byte initialization, provenance) upon such a native call. r? ``@RalfJung``
Following #126787, the purpose of this PR is to now enable Miri to execute native calls that make use of pointers.
Note that this PR does not yet implement any logic involved in updating Miri's "analysis" state (byte initialization, provenance) upon such a native call.
r? @RalfJung