https://bugs.kde.org/show_bug.cgi?id=452058

            Bug ID: 452058
           Summary: Generated suppressions contain a mix of mangled
                    (physical) and demangled (inline) frames
           Product: valgrind
           Version: unspecified
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: jsew...@acm.org
          Reporter: n.netherc...@gmail.com
  Target Milestone: ---

Put this Rust program in `a.rs`:

use std::io::{stdin, Read};
fn main() {
    let mut buf = vec![];

    if let Err(e) = stdin().read(&mut buf) {
        println!("{}", e)
    }
}

Then build it with: rustc a.rs

Then run: valgrind --leak-check=full --show-leak-kinds=all
--gen-suppressions=all ./a

Then hit enter, to provide the running program with necessary input.

On termination, Memcheck prints two suppressions. Here's the first one, which
is enough to show the problem:

{
   <insert_a_suppression_name_here>
   Memcheck:Leak
   match-leak-kinds: reachable
   fun:malloc
   fun:alloc
   fun:alloc_impl
   fun:allocate
   fun:exchange_malloc
   fun:new<std::sys::unix::mutex::Mutex>
   fun:from<std::sys::unix::mutex::Mutex>
   fun:_ZN3std10sys_common5mutex12MovableMutex3new17h4e64539bf4ba99a6E
   fun:new<std::io::buffered::bufreader::BufReader<std::io::stdio::StdinRaw>>
   fun:{closure#0}
  
fun:{closure#0}<std::sync::mutex::Mutex<std::io::buffered::bufreader::BufReader<std::io::stdio::StdinRaw>>,
std::io::stdio::stdin::{closure#0}>
  
fun:{closure#0}<std::sync::mutex::Mutex<std::io::buffered::bufreader::BufReader<std::io::stdio::StdinRaw>>,
std::lazy::{impl#10}::get_or_init::{closure#0}, !>
  
fun:_ZN3std4sync4once4Once15call_once_force28_$u7b$$u7b$closure$u7d$$u7d$17ha9375aeb05e4aae3E
   fun:_ZN3std4sync4once4Once10call_inner17hb3a655ef2ff7c156E
   fun:call_once_force<std::lazy::{impl#10}::initialize::{closure#0}>
   fun:_ZN3std4lazy21SyncOnceCell$LT$T$GT$10initialize17h3a3ef5fbb9e2970eE
  
fun:get_or_try_init<std::sync::mutex::Mutex<std::io::buffered::bufreader::BufReader<std::io::stdio::StdinRaw>>,
std::lazy::{impl#10}::get_or_init::{closure#0}, !>
  
fun:get_or_init<std::sync::mutex::Mutex<std::io::buffered::bufreader::BufReader<std::io::stdio::StdinRaw>>,
std::io::stdio::stdin::{closure#0}>
   fun:_ZN3std2io5stdio5stdin17h94821c2f5cbdd619E
   fun:_ZN1a4main17h8bbda9164eb1d7fdE
   fun:_ZN4core3ops8function6FnOnce9call_once17hb0b8acf7ed5a9c1fE
  
fun:_ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17hedc3d4705fc28138E
   fun:_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17h478bd93d3dae3c53E
   fun:call_once<(), (dyn core::ops::function::Fn<(), Output=i32> +
core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)>
   fun:do_call<&(dyn core::ops::function::Fn<(), Output=i32> +
core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32>
   fun:try<i32, &(dyn core::ops::function::Fn<(), Output=i32> +
core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)>
   fun:catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> +
core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32>
   fun:{closure#2}
   fun:do_call<std::rt::lang_start_internal::{closure#2}, isize>
   fun:try<isize, std::rt::lang_start_internal::{closure#2}>
   fun:catch_unwind<std::rt::lang_start_internal::{closure#2}, isize>
   fun:_ZN3std2rt19lang_start_internal17hd15a47be08101c28E
   fun:_ZN3std2rt10lang_start17h99d3162981a37fa3E
}

Suppressions are supposed to use *mangled* function names, but this has a mix
of mangled and demangled names. I did some digging and discovered that physical
stack frames are correctly showing as mangled, but inline stack frames are
incorrectly showing as demangled.

The Rust compiler tends to inline aggressively. This bug makes it very hard to
write suppressions, because frames that might be inlined one day might be
non-inlined later on after making moderate changes to a program.

This bug is preventing me from adding a useful suppression for the Rust
standard library. See https://github.com/rust-lang/rust/issues/80406 for
details.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to