Amanieu / minicov

Code coverage support for Rust `no_std` and embedded programs
Apache License 2.0
51 stars 11 forks source link

Segmentation fault on `rustc` nightly (from version 1.79.0) #19

Closed mstrug-rdx closed 4 months ago

mstrug-rdx commented 5 months ago

Summary

Using minicov with rustc version 1.79.0-nightly and up causes Segmentation fault.

Steps to reproduce

Preconditions

  1. Install rustc 1.79.0-nightly with command rustup install nightly-2024-03-21
  2. Set it as default toolchain: rustup default nightly-2024-03-21
  3. Verify version rustc --version

Reproduction

  1. Clone minicov repo
  2. Run export RUSTFLAGS="-Cinstrument-coverage -Zno-profiler-runtime"
  3. Build with cargo build command
  4. Run minicov-test with cargo run command

Current output:

b
Segmentation fault (core dumped)

Crash occurred. Same behaviour for rustc version 1.80.0-nightly.

Expected output:

b

No crash.

Environment

Tested on Ubuntu 20.04.6 LTS and Ubuntu 23.10 on architecture Amd64.

Analysis

Running rust-gdb tool gives following output:

Program received signal SIGSEGV, Segmentation fault.
0x000055555556130c in initializeValueProfRuntimeRecord (Data=0x5555555b21d0, SiteCountArray=0x7fffffffdad0)
    at c/InstrProfilingValue.c:315
315           Nodes ? RTRecord.NodesKind[I][J] : INSTR_PROF_NULLPTR;

Probably this is caused by some changes in latest llvm 18 version (introduced in rustc 1.79.0-nightly) in area of instr profile: https://github.com/llvm/llvm-project/commit/16e74fd48988ac95551d0f64e1b36f78a82a89a2