Skip to content

Rust 1.56 injected a valgrind incompatibility for Linux/AAarch64 #90316

Closed
@pnkfelix

Description

@pnkfelix

Code

I tried this code:

fn main() { let _n = std::time::Instant::now(); }

and ran it under valgrind.

I expected to see this happen: Successful program run with 0 errors from valgrind.

Instead, this happened:

$ valgrind ./target/debug/instant
==11772== Memcheck, a memory error detector
==11772== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==11772== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==11772== Command: ./target/debug/instant
==11772==
ARM64 front end: load_store
disInstr(arm64): unhandled instruction 0xC87F2D89
disInstr(arm64): 1100'1000 0111'1111 0010'1101 1000'1001
==11772== valgrind: Unrecognised instruction at address 0x11ffa4.
==11772==    at 0x11FFA4: atomic_umax<u128> (atomic.rs:2574)
==11772==    by 0x11FFA4: fetch_max (atomic.rs:1996)
==11772==    by 0x11FFA4: monotonize (monotonic.rs:91)
==11772==    by 0x11FFA4: monotonize (monotonic.rs:5)
==11772==    by 0x11FFA4: std::time::Instant::now (time.rs:270)
==11772==    by 0x10EB77: instant::main (main.rs:1)

Version it worked on

It most recently worked on: Rust 1.55

Version with regression

rustc --version --verbose:

rustc 1.56.0 (09c42c458 2021-10-18)
binary: rustc
commit-hash: 09c42c45858d5f3aedfa670698275303a3d19afa
commit-date: 2021-10-18
host: aarch64-unknown-linux-gnu
release: 1.56.0
LLVM version: 13.0.0

I also narrowed it down to which nightly injected the bug:

ubuntu@ip-172-31-93-250:~/instant$ cargo +nightly-2021-08-20 build
   Compiling instant v0.1.0 (/home/ubuntu/instant)
    Finished dev [unoptimized + debuginfo] target(s) in 0.66s
ubuntu@ip-172-31-93-250:~/instant$ valgrind ./target/debug/instant
==14475== Memcheck, a memory error detector
==14475== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==14475== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==14475== Command: ./target/debug/instant
==14475==
==14475==
==14475== HEAP SUMMARY:
==14475==     in use at exit: 0 bytes in 0 blocks
==14475==   total heap usage: 9 allocs, 9 frees, 1,977 bytes allocated
==14475==
==14475== All heap blocks were freed -- no leaks are possible
==14475==
==14475== For lists of detected and suppressed errors, rerun with: -s
==14475== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
ubuntu@ip-172-31-93-250:~/instant$ cargo +nightly-2021-08-21 build
   Compiling instant v0.1.0 (/home/ubuntu/instant)
    Finished dev [unoptimized + debuginfo] target(s) in 0.67s
ubuntu@ip-172-31-93-250:~/instant$ valgrind ./target/debug/instant
==14502== Memcheck, a memory error detector
==14502== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==14502== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==14502== Command: ./target/debug/instant
==14502==
ARM64 front end: load_store
disInstr(arm64): unhandled instruction 0xC87F2D89
disInstr(arm64): 1100'1000 0111'1111 0010'1101 1000'1001
==14502== valgrind: Unrecognised instruction at address 0x11f6a0.
==14502==    at 0x11F6A0: atomic_umax<u128> (atomic.rs:2574)
==14502==    by 0x11F6A0: fetch_max (atomic.rs:1996)
==14502==    by 0x11F6A0: monotonize (monotonic.rs:91)
==14502==    by 0x11F6A0: monotonize (monotonic.rs:5)
==14502==    by 0x11F6A0: std::time::Instant::now (time.rs:251)
==14502==    by 0x10E9F3: instant::main (main.rs:1)

which makes sense, because I believe this was injected by PR #83093

(The above transcript includes an invocation of valgrind, v 3.15.0, that is not the latest. But I did a build of 3.18 and reproduced the same bug there as well.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions