valgrind

Change pointer's value in function

早过忘川 提交于 2019-12-20 06:19:29
问题 I want to change the variable's value in the function. my code is like this: void change(char *buf){ char str = "xxxxxxx"; *buf = &str; } int main(){ char *xxx = NULL; change(xxx); } when I debug with valgrind, it says: ==3709== Invalid write of size 1 ==3709== at 0x80483CA: change (test.c:5) ==3709== by 0x80483E5: main (test.c:10) ==3709== Address 0x0 is not stack'd, malloc'd or (recently) free'd ==3709== ==3709== ==3709== Process terminating with default action of signal 11 (SIGSEGV) ==3709

What causes a random crash in boost::coroutine?

烂漫一生 提交于 2019-12-20 05:44:27
问题 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

Filtering out junk from valgrind output

时间秒杀一切 提交于 2019-12-20 02:28:18
问题 I'm trying to fix a memory leak in a very large project. Benchmarks have confirmed that memory leaks are a significant problem, and I'm working on finding the source of them. Running the project on a very simple case, I get ~850 potential memory leaks reported. All but about 5 of them look like: ==83597== 768 bytes in 3 blocks are possibly lost in loss record 743 of 864 ==83597== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==83597== by 0x548EF93: myproject

linux program HEAP tracker

我的未来我决定 提交于 2019-12-19 16:41:20
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 有时有些进程占用的内存非常高,但是想知道是什么数据占用,可以使用以下工具获取部分信息,因为进程的内存都是私有人,不可能直接读出,所以需要借助一些工具获取部分信息。 1、导出内存 dump memory 通常使用top命令查询Rss驻留的内存,找到相应的pid,再用lsof -p pid查看打开了哪些文件,可以优化比较大的文件,第三步pmap -X pid查看内存分配情况。如果发在[heap]类型占用的内存较大,那就要查找程序malloc分配了哪些内容占用内容(如果是第三方程序,就需要dump内存来查看个大概是什么内容在里了),dump内存的方法 #获取内存地址起止地址 #cat /proc/6086/maps 或#pmap 6086 #gdb --pid 1604 >dump memory /tmp/php-memory.dump 0x0146f000 0x06ebf000 --表示开始和结束内存地址(16进制) #查看数据 #strings -n 10 /tmp/php-memory.dump 2、查找内存 Valgrind http://valgrind.org/docs/manual/ms-manual.html Heaptrack http://milianw.de/blog/heaptrack-a

tracking uninitialized static variables

牧云@^-^@ 提交于 2019-12-19 06:26:29
问题 I need to debug an ugly and huge math C library, probably once produced by f2c. The code is abusing local static variables, and unfortunately somewhere it seems to exploit the fact that these are automatically initialized to 0. If its entry function is called with the same input twice, it is giving different results. If I unload the library and reload it again, it works correctly. It needs to be fast, so I would like to get rid of the load/unload. My question is that how to uncover these

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

做~自己de王妃 提交于 2019-12-19 05:22:21
问题 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

Should I worry about “Conditional jump or move depends on uninitialised value(s)”?

心已入冬 提交于 2019-12-19 03:44:05
问题 If you've used Memcheck (from Valgrind) you'll probably be familiar with this message... Conditional jump or move depends on uninitialized value(s) I've read about this and it simply occurs when you use an uninitialized value. MyClass s; s.DoStuff(); This will work because s is automatically initialized... So if this is the case, and it works, why does Memcheck tell me that it's uninitialized? Should the message be ignored? Perhaps I misunderstood where the error was directing me. From the

Make callgrind show all function calls in the kcachegrind callgraph

坚强是说给别人听的谎言 提交于 2019-12-19 03:38:24
问题 I was using valgrind tool - callgrind and kcachegrind for profiling a large project and was wondering if there is a way that callgrind reports the stats from all the functions (not just the most expensive functions). To be specific - When I visualized the callgraph in kcachegrind, it included only those functions that are quite expensive, but I was wondering if there is a way to include all the functions from the project in the callgraph. Command used for generating profiling info is given

Memory debugging tools for Android NDK C++ code

隐身守侯 提交于 2019-12-18 19:12:27
问题 Does anyone know of memory debugging tools (like Valgrind) for native C++ code under Android NDK? 回答1: We have a project that uses quite a bit of native code. As hinted in one of the comments for the question, the best approach is to test that code on another environment. We have a separate project that builds in Linux and calls the C/C++ functions we use in our Android code. Once you are at that point, all the nice tools you are used to (gdb, Valgrind, etc.) are available to you. A lot more

Memory debugging tools for Android NDK C++ code

旧城冷巷雨未停 提交于 2019-12-18 19:12:09
问题 Does anyone know of memory debugging tools (like Valgrind) for native C++ code under Android NDK? 回答1: We have a project that uses quite a bit of native code. As hinted in one of the comments for the question, the best approach is to test that code on another environment. We have a separate project that builds in Linux and calls the C/C++ functions we use in our Android code. Once you are at that point, all the nice tools you are used to (gdb, Valgrind, etc.) are available to you. A lot more