valgrind

How to install Valgrind on macOS Mojave(10.14) with Homebrew?

谁说胖子不能爱 提交于 2019-11-28 03:34:11
I tried to install Valgrind with command brew install Valgrind and I get a message says "valgrind: This formula either does not compile or function as expected on macOS versions newer than Sierra due to an upstream incompatibility. Error: An unsatisfied requirement failed this build." I tried to install with the command brew intall --HEAD Valgrind instead, after successfully installed the dependencies autoconf, automake and libtool, when it tries to install valgrind, I get a configure error: "Valgrind works on Darwin 10.x, 11.x, 12.x, 13.x, 14.x, 15.x, 16.x and 17.x (Mac OS X 10.6/7/8/9/10/11

MPI memory leak

為{幸葍}努か 提交于 2019-11-28 03:28:42
问题 I am writing some code that uses MPI and I was keeping noticing some memory leaks when running it with valgrind. While trying to identify where the problem was, I ended up with this simple (and totally useless) main: #include "/usr/include/mpi/mpi.h" int main(int argc,char** argv) { MPI_Init(&argc, &argv); MPI_Finalize(); return 0; } As you can see, this code doesn't do anything and shouldn't create any problem. However, when I run the code with valgrind (both in the serial and parallel case)

Proper way to initialize C++ structs

蹲街弑〆低调 提交于 2019-11-28 02:56:54
Our code involves a POD (Plain Old Datastructure) struct (it is a basic c++ struct that has other structs and POD variables in it that needs to get initialized in the beginning.) Based one what I've read , it seems that: myStruct = (MyStruct*)calloc(1, sizeof(MyStruct)); should initialize all the values to zero, as does: myStruct = new MyStruct(); However, when the struct is initialized in the second way, Valgrind later complains "conditional jump or move depends on uninitialised value(s)" when those variables are used. Is my understanding flawed here, or is Valgrind throwing false positives?

Memory leaks when using a singleton

雨燕双飞 提交于 2019-11-28 01:47:33
问题 I have a class in which I implement the singelton design pattern. I know some people don't think its a good idea, but it helps a lot, Anyway - I have a memory leak and vlagrind points me to these lines: _singleton = new Manager(); //Manager::instance() (Manager.cpp:18) And Manager::Manager() : _file(new ofstream), _tasks(new map<int, Task *>()), _idState(new map<int, int>()), _closing(false), _pending(false), _lock(new pthread_mutex_t), _endLock(new pthread_mutex_t), _cond(new pthread_cond_t)

Why does Valgrind not detect a memory leak in a Rust program using nightly 1.29.0?

给你一囗甜甜゛ 提交于 2019-11-28 01:11:55
I'm trying to detect a memory leak in a Rust program using Valgrind following this blog post . My source code is simply: #![feature(alloc_system)] extern crate alloc_system; use std::mem; fn allocate() { let bad_vec = vec![0u8; 1024*1024]; mem::forget(bad_vec); } fn main() { allocate(); } I expect the call to mem::forget() to generate a memory leak that Valgrind would be able to pick up on. However, when I run Valgrind, it reports that no leaks are possible: [memtest]> cargo run Compiling memtest v0.1.0 (file:///home/icarruthers/memtest) Finished dev [unoptimized + debuginfo] target(s) in 0

Does boost::bind() copy parameters by reference or by value?

僤鯓⒐⒋嵵緔 提交于 2019-11-28 00:11:00
Why does valgrind's DRD tool complaines "Conflicting load by thread ... at size 4": about such code: void SomeFunction(const int& value) { boost::bind(..., value); /* <-- complaines on this line with last backtrace function "new(int)" */ } Does boost::bind() stores values by reference or value? By value. 1 But you can make it copy by ref instead: void SomeFunction(const int& value) { boost::bind(..., boost::ref(value)); boost::bind(..., boost::cref(value)); // by const ref } 1 http://www.boost.org/doc/libs/1_46_1/libs/bind/bind.html#Purpose a copy of the value of i is stored into the function

Valgrind Unrecognised instruction

久未见 提交于 2019-11-27 23:27:14
I have the following code: #include <iostream> #include <random> int main() { std::mt19937_64 rng(std::random_device{}()); std::cout << std::uniform_int_distribution<>(0, 100)(rng) << '\n'; } I try to profile it using valgrind , but it says: vex amd64->IR: unhandled instruction bytes: 0xF 0xC7 0xF0 0x89 0x6 0xF 0x42 0xC1 vex amd64->IR: REX=0 REX.W=0 REX.R=0 REX.X=0 REX.B=0 vex amd64->IR: VEX=0 VEX.L=0 VEX.nVVVV=0x0 ESC=0F vex amd64->IR: PFX.66=0 PFX.F2=0 PFX.F3=0 ==2092== valgrind: Unrecognised instruction at address 0x4cdc1b5. ==2092== at 0x4CDC1B5:std::(anonymous namespace)::__x86_rdrand()

Valgrind: can possibly lost be treated as definitely lost?

六月ゝ 毕业季﹏ 提交于 2019-11-27 20:02:30
Can I treat the output of a Valgrind memcheck, "possibly lost" as "definitely lost"? Possibly lost, or “dubious”: A pointer to the interior of the block is found. The pointer might originally have pointed to the start and have been moved along, or it might be entirely unrelated. Memcheck deems such a block as “dubious”, because it's unclear whether or not a pointer to it still exists. Definitely lost, or “leaked”: The worst outcome is that no pointer to the block can be found. The block is classified as “leaked”, because the programmer could not possibly have freed it at program exit, since no

How do you tell Valgrind to completely suppress a particular .so file?

爱⌒轻易说出口 提交于 2019-11-27 19:20:06
I'm trying to use Valgrind on a program that I'm working on, but Valgrind generates a bunch of errors for one of the libraries that I'm using. I'd like to be able to tell it to suppress all errors which involve that library. The closest rule that I can come up with for the suppression file is { rule name Memcheck:Cond ... obj:/path/to/library/thelibrary.so } This doesn't entirely do the job, however. I have to create one of these for every suppression type that comes up (Cond, Value4, Param, etc), and it seems to still miss some errors which have the library in the stack trace. Is there a way

C strings, strlen and Valgrind

邮差的信 提交于 2019-11-27 18:19:19
问题 I'm trying to understand why Valgrind is spitting out : ==3409== Invalid read of size 8 ==3409== at 0x4EA3B92: __GI_strlen (strlen.S:31) whenever I'm applying strlen on a dynamically allocated string? Here is a short testcase : #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char *hello = "Hello World"; char *hello2; /* Step 1 */ printf("Step 1\n"); printf("strlen : %lu\n",(unsigned long)strlen(hello)); /* Step 2 */ hello2 = calloc(12,sizeof(char)); hello2[0] = 'H';