valgrind

Python memory leaks?

。_饼干妹妹 提交于 2019-12-01 04:08:50
I am writing a python extension that seems to be leaking memory. I am trying to figure out the soure of the problem using valgrind. However, it seems that python itself is leaking memory according to valgrind. Using the following simple script: hello.py print "Hello World!" and doing > valgrind --tool=memcheck python ./hello.py (...) ==7937== ERROR SUMMARY: 580 errors from 34 contexts (suppressed: 21 from 1) ==7937== malloc/free: in use at exit: 721,878 bytes in 190 blocks. ==7937== malloc/free: 2,436 allocs, 2,246 frees, 1,863,631 bytes allocated. ==7937== For counts of detected errors, rerun

Why would this give a Use of uninitialised value of size 8

佐手、 提交于 2019-12-01 04:04:05
In my code I have a class named membrane with a function named exciteMod() , a function named decide() and a variable named delta_U . The first line of exciteMod() is this->delta_U = 0 . In decide() I have an exponent of -delta_U ( exp(-this->delta_U) ). which cause an error Use of uninitialised value of size 8. What might cause this? I don't have any error about delta_U which is generated in valgrind. Edit: Here are the relevant segment of the code: void membrane::exciteMod(){ this->delta_U = 0; /* Do some stuff which does not directly affect this->delta_U*/ std::tr1::shared_ptr<bead> bit =

Valgrind does not show line-numbers

微笑、不失礼 提交于 2019-12-01 03:57:28
I'm trying to find out where I made invalid writes to a piece of memory using Valgrind. It tells there is such an issue, also in what function, but not in what line. Although the function is quite small, I'd like to have the line-number shown in Valgrind. I've seen this on some outputs of Valgrind, but currently they are not shown, and I wonder why. The output is the following: niklas@emerald:~/Arbeitsfläche/spyr/bin/Debug$ valgrind --tool=memcheck --leak-check=full --show-reachable=yes ./spyr [...] ==4404== Invalid write of size 4 ==4404== at 0x8048849: sp_ParticleBuffer_init (in /home/niklas

Clang link-time optimization with replaced operator new causes mismatched free()/delete in valgrind

和自甴很熟 提交于 2019-12-01 03:57:01
问题 When using clang 3.5.0 with -flto and linking with a shared library, it seems that calls to operator delete in the shared library don't follow the same symbol resolution order as calls to operator new from the main objects. Example: shared.cpp : void deleteIt(int* ptr) { delete ptr; } main.cpp : #include <cstdlib> #include <new> void* operator new(size_t size) { void* result = std::malloc(size); if (result == nullptr) { throw std::bad_alloc(); } return result; } void operator delete(void* ptr

Valgrind legitimate “possibly lost” bytes example

流过昼夜 提交于 2019-12-01 03:56:07
I saw that valgrind classifies memory leaks into: definitely lost indirectly lost possibly lost still reachable suppressed I just fixed a leak where the "possibly lost" was the main problem. The documentation says : " possibly lost means your program is leaking memory, unless you're doing unusual things with pointers that could cause them to point into the middle of an allocated block; see the user manual for some possible causes" May I please know an example of " doing unusual things with pointers that could cause them to point into the middle of an allocated block " ? I mean an example where

Valgrind… 4 bytes inside a block of size 8 free'd

本秂侑毒 提交于 2019-12-01 03:37:05
I'm getting this error in Valgrind after attempting to free a list. print_list dumps the list to the syslog. I'm pretty confident that output is correct. Valgrind: ==7028== 1 errors in context 1 of 10: ==7028== Invalid read of size 4 ==7028== at 0x8049603: free_list (list.c:239) ==7028== by 0x80488B5: m61_close_for_valgrind (m61.c:36) ==7028== by 0x8048825: main (mytest.c:19) ==7028== Address 0x420006c is 4 bytes inside a block of size 8 free'd ==7028== at 0x4028F0F: free (vg_replace_malloc.c:446) ==7028== by 0x804960C: free_list (list.c:239) ==7028== by 0x80488B5: m61_close_for_valgrind (m61

Valgrind errors when linked with -static — Why?

懵懂的女人 提交于 2019-12-01 03:28:27
I have a test driver linked to a library I wrote. The library uses autotools so it produces both an archive (.a file) and a dynamic library (.so). When I link my driver with 'g++ -static', presumably linking to the .a, valgrind lights up complaining repeatedly 'Conditional jump or move depends on uninitialised value(s)'. The first failure occurs before main in __pthread_initialize_minimal. When I link without -static, presumably linking with the .so, I don't get any valgrind complaints. Does anyone know why? Does valgrind just not work with -static? UPDATE : I can't post even a pared down

How do you get Valgrind to show line errors?

为君一笑 提交于 2019-12-01 03:15:25
问题 How do you get Valgrind to show exactly where an error occured? I compiled my program (on a Windows machine over a Linux terminal via PuTTy) adding the -g debug option. When I run Valgrind, I get the Leak and Heap summary, and I definitely have lost memory, but I never get information about where it happens (file name, line). Shouldn't Valgrind be telling me on what line after I allocate memory, it fails to deallocate later? ==15746== ==15746== HEAP SUMMARY: ==15746== in use at exit: 54 bytes

C++'s std::string pools, debug builds? std::string and valgrind problems

喜欢而已 提交于 2019-12-01 03:06:29
I have a problem with many valgrind warnings about possible memory leaks in std::string, like this one: 120 bytes in 4 blocks are possibly lost in loss record 4,192 of 4,687 at 0x4A06819: operator new(unsigned long) (vg_replace_malloc.c:230) by 0x383B89B8B0: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib64/libstdc++.so.6.0.8) by 0x383B89C3B4: (within /usr/lib64/libstdc++.so.6.0.8) by 0x383B89C4A9: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, unsigned long, std::allocator<char> const&) (in

Valgrind Warning: Should I Take It Seriously

若如初见. 提交于 2019-12-01 02:57:57
问题 Background: I have a small routine that mimics fgets(character, 2, fp) except it takes a character from a string instead of a stream. newBuff is dynamically allocated string passed as a parameter and character is declared as char character[2] . Routine: character[0] = newBuff[0]; character[1] = '\0'; strcpy(newBuff, newBuff+1); The strcpy replicates the loss of information as each character is read from it. Problem: Valgrind does warns me about this activity, "Source and destination overlap