Skip to content

miri: printing with full mir doesn't work because of pointer aligning inside memrchr #50567

Closed
@bjorn3

Description

@bjorn3

let end_align = (ptr as usize + len) & (usize_bytes - 1);

error: a raw memory access tried to access part of a pointer value as raw bytes

error[E0080]: constant evaluation error
   --> /Users/bjorn/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libcore/slice/memchr.rs:106:21
    |
106 |     let end_align = (ptr as usize + len) & (usize_bytes - 1);
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ a raw memory access tried to access part of a pointer value as raw bytes
    |
note: inside call to `core::slice::memchr::memrchr`
   --> /Users/bjorn/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/sys/unix/memchr.rs:53:9
    |
53  |         ::core::slice::memchr::memrchr(needle, haystack)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside call to `std::sys::unix::memchr::memrchr::memrchr_specific`
   --> /Users/bjorn/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/sys/unix/memchr.rs:56:5
    |
56  |     memrchr_specific(needle, haystack)
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside call to `std::sys::unix::memchr::memrchr`
   --> /Users/bjorn/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/memchr.rs:55:5
    |
55  |     ::sys::memchr::memrchr(needle, haystack)
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside call to `std::memchr::memrchr`
   --> /Users/bjorn/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/io/buffered.rs:905:23
    |
905 |         let i = match memchr::memrchr(b'/n', buf) {
    |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside call to `<std::io::LineWriter<W> as std::io::Write><std::io::stdio::Maybe<std::io::stdio::StdoutRaw>>::write`
   --> /Users/bjorn/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/io/stdio.rs:465:9
    |
465 |         self.inner.borrow_mut().write(buf)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside call to `<std::io::StdoutLock<'a> as std::io::Write>::write`
   --> /Users/bjorn/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libstd/io/mod.rs:1111:19
    |
1111|             match self.write(buf) {
    |                   ^^^^^^^^^^^^^^^
[...]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions