-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add debug assertions to raw pointer methods testing for unaligned/NULL pointers #53871
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I might be interested in working on that. Could you help me with a starting point for that? |
You might want to start with https://doc.rust-lang.org/nightly/std/ptr/fn.write_bytes.html. It could get a check similar to Line 4883 in 7164a9f
To avoid code duplication, consider adding a (private) helper method in Other candidates besides |
Sorry for the delay, it took me a while to free up some time. Quick questions:
|
Ah, intrinsics are still written in Rust, but as code generation functions. Well, I guess adding debug assertions everywhere in the intrinsics would be counter-productive, so we're going for the wrapper? Although, I'm not sure how to cleanly hijack the interface: I have to keep using the same function name for the callers, so that I don't have to change their code, but unless I don't understand how it works, I also need to have the same signature including the function name for the code generation. How should I proceed? |
Ah good point, I forgot about these reexports. I think the right way forward is to replace this line by a wrapper function that just calls the intrinsic. The docs should be moved from The, in the 2nd step, you can add the
Sorry, I meant the one in |
Wrap write_bytes in a function. Move docs This will allow us to add debug assertions. See issue #53871.
Wrap write_bytes in a function. Move docs This will allow us to add debug assertions. See issue rust-lang#53871.
Wrap write_bytes in a function. Move docs This will allow us to add debug assertions. See issue rust-lang#53871.
Wrap write_bytes in a function. Move docs This will allow us to add debug assertions. See issue #53871.
@nitnelave Congrats, your patch landed. :) So with the preparation out of the way, let me know if you need any help with adding the debug assertions. |
Thanks! I should be okay, I just need to find the time :) I'll ping you
when it's ready for review.
…On Tue, Feb 26, 2019 at 9:45 AM Ralf Jung ***@***.***> wrote:
@nitnelave <https://github.com/nitnelave> Congrats, your patch landed. :)
So with the reparation out of the way, let me know if you need any help
with adding the debug assertions.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#53871 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAwn2aSaZalWPVSbL7bsRV1f3cd3QvYhks5vRPQLgaJpZM4WV2qN>
.
|
Cc #51713 |
get rid of real_intrinsics module instead import intrinsics locally in their wrapper functions. (These functions are wrapper functions as a preparation to fixing rust-lang#53871.)
Add debug assertions to write_bytes and copy* Looks like @nitnelave went MIA in rust-lang#58783, so I am re-submitting their PR, tweaked just a bit. I took care to preserve commit authorship. Cc rust-lang#53871
Add debug assertions to write_bytes and copy* Looks like @nitnelave went MIA in rust-lang#58783, so I am re-submitting their PR, tweaked just a bit. I took care to preserve commit authorship. Cc rust-lang#53871
Add debug assertions to write_bytes and copy* Looks like @nitnelave went MIA in rust-lang#58783, so I am re-submitting their PR, tweaked just a bit. I took care to preserve commit authorship. Cc rust-lang#53871
Add debug assertions to write_bytes and copy* Looks like @nitnelave went MIA in rust-lang#58783, so I am re-submitting their PR, tweaked just a bit. I took care to preserve commit authorship. Cc rust-lang#53871
Add debug assertions to write_bytes and copy* Looks like @nitnelave went MIA in rust-lang#58783, so I am re-submitting their PR, tweaked just a bit. I took care to preserve commit authorship. Cc rust-lang#53871
Add debug assertions to write_bytes and copy* Looks like @nitnelave went MIA in rust-lang#58783, so I am re-submitting their PR, tweaked just a bit. I took care to preserve commit authorship. Cc rust-lang#53871
Add debug assertions to write_bytes and copy* Looks like @nitnelave went MIA in rust-lang#58783, so I am re-submitting their PR, tweaked just a bit. I took care to preserve commit authorship. Cc rust-lang#53871
Add debug assertions to write_bytes and copy* Looks like @nitnelave went MIA in rust-lang#58783, so I am re-submitting their PR, tweaked just a bit. I took care to preserve commit authorship. Cc rust-lang#53871
Add debug assertions to write_bytes and copy* Looks like @nitnelave went MIA in rust-lang#58783, so I am re-submitting their PR, tweaked just a bit. I took care to preserve commit authorship. Cc rust-lang#53871
…acrum debug_assert a few more raw pointer methods Fixes rust-lang#53871
…acrum debug_assert a few more raw pointer methods Fixes rust-lang#53871
…acrum debug_assert a few more raw pointer methods Fixes rust-lang#53871
…acrum debug_assert a few more raw pointer methods Fixes rust-lang#53871
…acrum debug_assert a few more raw pointer methods Fixes rust-lang#53871
debug_assert a few more raw pointer methods Fixes #53871
debug_assert a few more raw pointer methods Makes progress for #53871
Uh oh!
There was an error while loading. Please reload this page.
In #53783, we document more precisely the rules for the various methods that can be used to access memory through raw pointers. In particular, we clarify that the pointer must be non-NULL and aligned even when the access has size 0.
This issue is about helping people find bugs in libstd by adding a
debug_assert!
to all these methods testing that condition, similar to what I did for from_raw_parts. I suggest to add a helper method to raw pointers to test this, and also use that forfrom_raw_parts
andfrom_raw_parts_mut
.This may uncover issues in libstd, uncovering misuses of these methods. Those should then be fixed.
The text was updated successfully, but these errors were encountered: