Bug 281449

Summary: Addresses of unloaded modules are not translated to functions during "HEAP SUMMARY" report
Product: [Developer tools] valgrind Reporter: Zohar Gofer <zoharg>
Component: memcheckAssignee: Julian Seward <jseward>
Status: RESOLVED DUPLICATE    
Severity: minor CC: tom
Priority: NOR    
Version: 3.6 SVN   
Target Milestone: ---   
Platform: RedHat Enterprise Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Perl script to fix unknown addresses in HEAP SUMMARY

Description Zohar Gofer 2011-09-06 06:46:14 UTC
Created attachment 63428 [details]
Perl script to fix unknown addresses in HEAP SUMMARY

I am using these options:
  --leak-check=full --track-origins=yes -v --log-file=/data/core-valgrind.log

My program is compiled for x86_64 with gcc 4.5.1 and loads many modules dynamically. Error reports during normal operation are fine, but the heap report at the exit is useless, because valgrind fails to translate addresses of unloaded modules to functions.

Example:
==25581== HEAP SUMMARY:
<removed lines>
==25581== 24 bytes in 1 blocks are definitely lost in loss record 15 of 80
==25581==    at 0x4906CF7: operator new(unsigned long) (vg_replace_malloc.c:261)
==25581==    by 0xAB61715: ???
==25581==    by 0xA92B7D6: ???
==25581==    by 0xA92CE17: ???
==25581==    by 0xA92F1BB: ???
==25581==    by 0x8D90E03: ???
==25581==    by 0x8D94C40: ???

I have developed a script based on addr2line to work this problem around. The script is attached.

After running the script, this is what I get:
==25581== HEAP SUMMARY:
<removed lines>
==25581== 24 bytes in 1 blocks are definitely lost in loss record 15 of 80
==25581==    at 0x4906CF7: operator new(unsigned long) (vg_replace_malloc.c:261)
==25581==    by 0xAB61715: ibasicIO::CMgrFileFactory::OpenMgrFile(bool) (Factory.cpp:171)
==25581==    by 0xA92B7D6: irepository::CRepositoryFactory::CRepositoryFactory() (CRepositoryFactory.cpp:83)
==25581==    by 0xA92CE17: irepository::CRepositoryFactory::msCreate() (CRepositoryFactory.cpp:599)
==25581==    by 0xA92F1BB: LoadSubCmpnt (RepositoryMSWIN.cpp:99)
==25581==    by 0x8D90E03: CCmDll::mLoadCmpnt(char const*, void**) (cmDll.cpp:104)
==25581==    by 0x8D94C40: CCmMgr::LoadCmpnt(char const*, void**) (CmpntMgr.cpp:298)

I hope people find this workaround helpful. All the information is there, and this can be done by valgrind instead of externally using addr2line.

Thanks
Comment 1 Tom Hughes 2011-09-06 07:16:29 UTC

*** This bug has been marked as a duplicate of bug 79362 ***