valgrind massif为什么不报告任何函数名或代码引用?
我有一个程序意外使用大量堆(大约3GB).我通过valgrind memcheck进行了测试,该报告没有泄漏,声称所有堆内存仍然可以访问.
I have a program that is unexpectedly using a large amount of heap (about 3GB). I ran it through valgrind memcheck which reported no leaks, claiming that all the heap memory is still reachable.
因此,我使用调试选项重建了所有库,并通过valgrind massif运行了编.我使用的是Valgrind-3.8.1,我今天下载并在盒子上构建了它.命令行是:
So I rebuilt all my libraries with debug options, and ran the prog through valgrind massif. I am using Valgrind-3.8.1 which I just downloaded and built on my box today. The command line was:
valgrind --tool=massif myprog
Valgrind没有产生错误或警告.生成的输出文件报告了所有已分配的内存,但是大分配的所有堆栈跟踪都无法识别函数名称或代码位置,例如:
Valgrind produced no errors or warnings. The resulting output file is reporting all the allocated memory, but all the stack traces for the large allocations fail to identify the function names or code locations, e.g.:
97.34% (2,595,141,447B) (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
->88.67% (2,363,882,948B) 0xCA6ACC0: ???
| ->88.67% (2,363,882,948B) 0xC7D7A71: ???
| ->88.67% (2,363,882,948B) 0xC7D705E: ???
| ->88.67% (2,363,882,948B) 0xA6ACB65: ???
| ->59.01% (1,573,247,120B) 0xA6AC9BA: ???
| | ->59.01% (1,573,247,120B) 0x9410C08: ???
| | ->59.01% (1,573,247,120B) 0x94123E2: ???
| | ->59.01% (1,573,247,120B) 0x940B3E9: ???
| | ->59.01% (1,573,247,120B) 0x9428BC0: ???
| | ->59.01% (1,573,247,120B) 0x98B0564: ???
| | ->59.01% (1,573,247,120B) 0x9AF0DA0: ???
| | ->59.01% (1,573,247,120B) 0x9AF09BE: ???
| | ->59.01% (1,573,247,120B) 0x9AF0E6C: ???
| | ->59.01% (1,573,247,120B) 0x4CE6438: run_S (Thread.cpp:98)
| | ->59.01% (1,573,247,120B) 0x3A9A40683B: start_thread (in /lib64/libpthread-2.5.so)
| | ->59.01% (1,573,247,120B) 0x3A994D503B: clone (in /lib64/libc 2.5.so)
我现在有点卡住了.我想知道我构建的库是否实际上未启用调试功能,但是当我在gdb中运行代码时,它确实具有所有调试信息.另外,在massif输出中还有其他一些(小得多)的内存分配结果,这些结果可以从我的代码中识别出函数名和位置.
I am a bit stuck now. I wondered if the libraries I have built actually did not have debug enabled - but when I run my code in gdb it does appear to have all the debug info. Also, there are a few other (much smaller) memory allocation results in the massif output that identify a function name and location from my code.
这些结果是否表明系统或外部库中的堆栈跟踪?那就是为什么没有信息吗?谁能建议我如何跟踪这些分配?
Do these results indicate stack traces in system or external libraries? Is that why there is no info? Can anyone suggest how I can track these allocations down?
认为答案是RTFM ...请参见valgrind 常见问题解答第4.2节:
Think the answer is RTFM...see the valgrind FAQ section 4.2:
此外,对于涉及共享对象的泄漏报告,如果共享对象是在程序终止之前卸载,Valgrind将放弃调试信息和错误消息将充满???条目.解决方法这是为了避免在这些共享库上调用dlclose.
Also, for leak reports involving shared objects, if the shared object is unloaded before the program terminates, Valgrind will discard the debug information and the error message will be full of ??? entries. The workaround here is to avoid calling dlclose on these shared objects.
我的代码确实确实在退出之前显式卸载了其共享库.我正在重建库,抑制了库的卸载-希望有更好的结果:)
My code does indeed explicitly unload its shared libs before exit. I am rebuilding with the library unloads suppressed - hope for a better result :)