Search code examples
rustvalgrind

Rust binary stuck when started with valgrind


I am trying to perform some leak check for my binary that has been generated from a Rust project by doing cargo build --release

I am using valgrind for the purpose and here is my command

valgrind  --leak-check=full  --show-leak-kinds=all ./binary 

However after this instruction, I get the following information on the shell

==1732828==    by 0x3553B4: binary::main (in /home/user/Desktop/binary)
==1732828==    by 0x31EF52: std::sys_common::backtrace::__rust_begin_short_backtrace (in /home/user/Desktop/binary)
==1732828==    by 0x289588: _ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17hcb45a478cf2544afE.llvm.17780275718652616296 (in /home/user/Desktop/binary)
==1732828==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==1732828== 
==1732828== Warning: unimplemented fcntl command: 1036

The binary gets stuck after this warning unimplemented fcntl command.

When I run without valgrind, the operation of the project binary is normal. Is it possible to deduce the reason for this behavior from the warnings presented?


Solution

  • As far as I can tell there are two problems. Possibly three.

    1. An error in your code that you need to fix.
    2. The fcntl 'HINTS' aren't supported by Valgrind https://github.com/torvalds/linux/blob/master/include/uapi/linux/fcntl.h
    3. Valgrind ought to demangle rust symbols, so there may be a problem there.