valgrind

Valgrind hangs in pthread_spin_lock consuming 100% CPU

半城伤御伤魂 提交于 2019-12-02 06:50:40
问题 My C++ multi threaded application hangs in pthread_spin_lock in valgrind versions 3.8.0 and latest. But it is not happening in 3.6.0, 3.6.1 and 3.7.0. Anyone knows any workaround for this? 回答1: This is cause the internal problems of thread managing in valgrind. I had same problem and it was fixed in 3.10 version of valgrind. 回答2: The issue logged in the valgrind official issue management system. Julian Seward has fixed it in 3.9 later version. https://bugs.kde.org/show_bug.cgi?id=336435 来源:

Analysis of Valgrind log for boost::uuid

泄露秘密 提交于 2019-12-02 04:51:27
I am using boost::uuid in order to generate unique ids: string UUid() { boost::uuids::uuid uuid = boost::uuids::random_generator()(); return boost::lexical_cast<std::string>(uuid); } When I use valgrind in order to analyse my code i get the following remarks: Valgrind log ==47807== Conditional jump or move depends on uninitialised value(s) ==47807== at 0x441D19: void boost::random::mersenne_twister_engine<unsigned int, 32ul, 624ul, 397ul, 31ul, 2567483615u, 11ul, 4294967295u, 7ul, 2636928640u, 15ul, 4022730752u, 18ul, 1812433253u>::seed<boost::uuids::detail::generator_iterator<boost::uuids:

User Leak, libc++ leak or false positive

无人久伴 提交于 2019-12-02 04:20:34
问题 I am building a dynamic library on mac in C++11 using the clang compiler and libc++ standard library. When I run valgrind on my test code which links to my dynamic library I get one block of memory that is definitely lost. Here is the valgrind report: ==45659== 36 bytes in 1 blocks are definitely lost in loss record 57 of 228 ==45659== at 0x66BB: malloc (vg_replace_malloc.c:300) ==45659== by 0x31EAB0: __Balloc_D2A (in /usr/lib/system/libsystem_c.dylib) ==45659== by 0x31F2A5: __d2b_D2A (in

Valgrind shows std::vector<> times of alloc is more than free, but no memory leak

不问归期 提交于 2019-12-02 03:30:35
问题 The code is fairly simple: #include <vector> int main() { std::vector<int> v; } Then I build and run it with Valgrind: g++ test.cc && valgrind ./a.out ==8511== Memcheck, a memory error detector ==8511== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. ==8511== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info ==8511== Command: ./a.out ==8511== ==8511== ==8511== HEAP SUMMARY: ==8511== in use at exit: 72,704 bytes in 1 blocks ==8511== total heap usage: 1 allocs,

C Linked List valgrind Invalid Read of Size

南笙酒味 提交于 2019-12-02 03:10:23
I have a problem with my Linked List and the valgrind output. Without further adieu here is my linked list: typedef struct Map map; struct Map { void *address; double free_time; map* next; }*map_list; The list is created using a dummy head node. As you can see, the struct holds an address and a free time, which I try to associate them. In the find_and_free function I search this list using a time and if this time is smaller than the one stored in the list, I deallocate the saved address. And then I deallocate the list node as well. This is the function used to find any free time that is

What causes a random crash in boost::coroutine?

浪子不回头ぞ 提交于 2019-12-02 03:00:21
I have a multithread application which uses boost::asio and boost::coroutine via its integration in boost::asio . Every thread has its own io_service object. The only shared state between threads are connection pools which are locked with mutex when connection is get or returned from/to the connection pool. When there is not enough connections in the pool I push infinite asio::steady_tiemer in internal structure of the pool and asynchronously waiting on it and I yielding from the couroutine function. When other thread returns connection to the pool it checks whether there is waiting timers, it

What is a minimal example of an Rc dependency cycle?

*爱你&永不变心* 提交于 2019-12-02 00:37:41
问题 I'm trying to write a Rust program that leaks memory due to cycles with reference counts. The following example, which seems like it should cause a memory leak, does not leak memory according to Valgrind. What gives? test.rs : use std::cell::RefCell; use std::rc::Rc; struct Foo { f: Rc<Bar>, } struct Bar { b: RefCell<Option<Rc<Foo>>>, } fn main() { let bar = Rc::new(Bar { b: RefCell::new(None), }); let foo = Rc::new(Foo { f: bar.clone() }); *bar.b.borrow_mut() = Some(foo.clone()); } Valgrind

Leaking memory with pthreads

余生长醉 提交于 2019-12-02 00:29:37
问题 I'm using pthreads and according to valgrind I am leaking memory, like in valgrind memory leak errors when using pthread_create The top answer says that if you pthread_join all the threads this memory will be reclaimed, but it isn't for me. pthread_t threads[NUM_THREADS]; ... for (i = 0; i < NUM_THREADS; i++) { pthread_create(&threads[i], &attr, Worker, NULL); } ... for (i = 0; i < NUM_THREADS; i++) { pthread_join(threads[i], NULL); } valgrind output ==2707== HEAP SUMMARY: ==2707== in use at

CMake简介,打包so文件,编译实际项目 用valgrind测内存情况

二次信任 提交于 2019-12-01 23:47:15
CMake简介和使用示例 CMake是常用的跨平台编译器。图像这块在给服务端做开发时,常有两个需求: (1)代码打成.so包,供别人调用; (2)编译、测试,用valgrind测内存情况。 工程较大时,借助CMake完成很方便。下面分别给出两种情况下,CMakeLists.txt的简单示例。 1. 借助CMake打.so包 把目录utils下的文件打出.so包。 其中CMakeLists.txt内容: cmake_minimum_required(VERSION 2.8) aux_source_directory(. utils_src) add_library(utils SHARED ${utils_src}) set_target_properties(utils PROPERTIES output_name "utils") 注意:前面的关键字可以大写也可以小写,括号内的关键字必须大写。 编译: cmake . make 生成了共享库libutils.so 2. 编译实际的项目 项目sticker_me中文件结构如下,其中build目录用于生成编译的结果。 它们之间的调用关系如下: 各个CMakeLists.txt如下: ./CMakeLists.txt: cmake_minimum_required(VERSION 2.8) project(sticker_me) add

C++ program dies with std::bad_alloc, BUT valgrind reports no memory leaks

岁酱吖の 提交于 2019-12-01 22:31:59
My program fails with 'std::bad_alloc' error message. The program is scalable, so I've tested on a smaller version with valgrind and there are no memory leaks. This is an application of statistical mechanics, so I am basically making hundreds of objects, changing their internal data (in this case stl vectors of doubles), and writing to a datafile. The creation of objects lies inside a loop, so when it ends the memory is free. Something like: for (cont=0;cont<MAX;cont++){ classSection seccion; seccion.GenerateObjects(...); while(somecondition){ seccion.evolve(); seccion.writedatatofile(); }} So