Valgrind problems

Dear Rooters

As suggested by Rene I am testing my program with valgrind and get leaks and other
messages which in my opinion should not appear.
I am attaching a short program “MyGui” which is able to reproduce these messages
of valgrind (although I cannot find any bugs in program MyGui).

The following three Menu selections in MyGui result in valgrind messages:
1, When exiting MyGui (Menu->File->Exit), valgrind reports memory leaks.
2, When opening TGFileDialog (Menu->File->Open), valgrind reports uninitialized values.
3, When opening TBrowser (Menu->Tools->Browser), valgrind reports uninitialized values.

In addition, even before main() calls the main class MyFrame valgrind reports
uninitialized values (see attached file “valgrind_output_Exit.txt”).

Since I do not understand the reason for these messages, especially I cannot
find any memory leaks in my program code for MyGui, I would appreciate any
hints why these messages appear, and especially, where the memory leaks are?

The following are excerpts of the valgrind messages, the complete output is shown
in the attached “valgrind_output_Menu.txt” files.
(I am using FC4 with root 5.11/03 from 20 April 2006)

1, Menu->File->Exit (complete output is attached “valgrind_output_Exit.txt”):

==3380== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 75 from 3)
==3380== malloc/free: in use at exit: 19110404 bytes in 32334 blocks.
==3380== malloc/free: 147020 allocs, 114686 frees, 35259504 bytes allocated.
==3380== For counts of detected errors, rerun with: -v
==3380== searching for pointers to 32334 not-freed blocks.
==3380== checked 21846652 bytes.
==3380== 
==3380== 
==3380== 49 bytes in 16 blocks are definitely lost in loss record 66 of 169
==3380==    at 0x1B909222: malloc (vg_replace_malloc.c:130)
==3380==    by 0x1C1DDD59: G__memfunc_para_setup (in /home/Rabbitus/ROOT/root/lib/libCint.so)
==3380==    by 0x1C1DE00E: G__parse_parameter_link (in /home/Rabbitus/ROOT/root/lib/libCint.so)
==3380==    by 0x1C1DE305: G__memfunc_setup (in /home/Rabbitus/ROOT/root/lib/libCint.so)
==3380==    by 0x1D18118D: G__cpp_setup_func3() (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3380==    by 0x1D181251: G__cpp_setup_funcG__Gui1 (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3380==    by 0x1D182901: G__cpp_setupG__Gui1 (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3380==    by 0x1C1C7788: G__call_setup_funcs (in /home/Rabbitus/ROOT/root/lib/libCint.so)
==3380==    by 0x1D1A289E: G__cpp_setup_initG__Gui1::G__cpp_setup_initG__Gui1() (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3380==    by 0x1D19A194: __static_initialization_and_destruction_0(int, int) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3380==    by 0x1D19A1CC: _GLOBAL__I__ZN4ROOT20GenerateInitInstanceEPK8TGClient (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3380==    by 0x1D3021E9: (within /home/Rabbitus/ROOT/root/lib/libGui.so)
==3380== 
==3380== 
==3380== 54 bytes in 3 blocks are definitely lost in loss record 67 of 169
==3380==    at 0x1B9095DA: operator new[](unsigned) (vg_replace_malloc.c:138)
==3380==    by 0x1BAA0B31: TROOT::GetClass(char const*, bool) const (in /home/Rabbitus/ROOT/root/lib/libCore.so)
==3380==    by 0x1BAA0D99: TROOT::IgnoreInclude(char const*, char const*) (in /home/Rabbitus/ROOT/root/lib/libCore.so)
==3380==    by 0x1BB05B1F: IgnoreInclude (in /home/Rabbitus/ROOT/root/lib/libCore.so)
==3380==    by 0x1C1CEAAA: G__loadfile (in /home/Rabbitus/ROOT/root/lib/libCint.so)
==3380==    by 0x1C2145E8: G__loadsystemfile (in /home/Rabbitus/ROOT/root/lib/libCint.so)
==3380==    by 0x1BB085AB: TCint::Load(char const*, bool) (in /home/Rabbitus/ROOT/root/lib/libCore.so)
==3380==    by 0x1BAB9267: TSystem::Load(char const*, char const*, bool) (in /home/Rabbitus/ROOT/root/lib/libCore.so)
==3380==    by 0x1BB98A79: TUnixSystem::Load(char const*, char const*, bool) (in /home/Rabbitus/ROOT/root/lib/libCore.so)
==3380==    by 0x1BA9D474: TROOT::LoadClass(char const*, char const*, bool) (in /home/Rabbitus/ROOT/root/lib/libCore.so)
==3380==    by 0x1BA88AB2: TPluginHandler::LoadPlugin() (in /home/Rabbitus/ROOT/root/lib/libCore.so)
==3380==    by 0x1BA39ED9: TApplication::TApplication(char const*, int*, char**, void*, int) (in /home/Rabbitus/ROOT/root/lib/libCore.so)
==3380== 
         etc
==3380== 
==3380== LEAK SUMMARY:
==3380==    definitely lost: 11199 bytes in 35 blocks.
==3380==    indirectly lost: 283483 bytes in 1116 blocks.
==3380==      possibly lost: 184306 bytes in 4051 blocks.
==3380==    still reachable: 18631416 bytes in 27132 blocks.
==3380==         suppressed: 0 bytes in 0 blocks.

2, Menu->File->Open (complete output is attached “valgrind_output_Open.txt”):

==3401== Conditional jump or move depends on uninitialised value(s)
==3401==    at 0x1D05773B: TGLBContainer::HandleButton(Event_t*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3401==    by 0x1D0372D7: TGFrame::HandleEvent(Event_t*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3401==    by 0x1D0118A8: TGClient::HandleMaskEvent(Event_t*, unsigned long) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3401==    by 0x1D011C5C: TGClient::ProcessOneEvent() (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3401==    by 0x1D011CE9: TGClient::HandleInput() (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3401==    by 0x1D011D23: TGInputHandler::Notify() (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3401==    by 0x1BB9D955: TUnixSystem::DispatchOneEvent(bool) (in /home/Rabbitus/ROOT/root/lib/libCore.so)
==3401==    by 0x1BAB63B7: TSystem::InnerLoop() (in /home/Rabbitus/ROOT/root/lib/libCore.so)
==3401==    by 0x1D012007: TGClient::WaitForUnmap(TGWindow*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3401==    by 0x1D01EDBB: TGComboBoxPopup::PlacePopup(int, int, unsigned, unsigned) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3401==    by 0x1D01EED7: TGComboBox::HandleButton(Event_t*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3401==    by 0x1D037271: TGFrame::HandleEvent(Event_t*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3401== 
==3401== Conditional jump or move depends on uninitialised value(s)
==3401==    at 0x1EC3D4D4: convert_xpm_scanline (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3401==    by 0x1EC2793B: xpm_file2ASImage (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3401==    by 0x1EC27A2C: xpm2ASImage (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3401==    by 0x1EC29BD2: file2ASImage_extra (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3401==    by 0x1EC29E0E: file2ASImage (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3401==    by 0x1EBE86D7: TASImage::ReadImage(char const*, TImage::EImageFileTypes) (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3401==    by 0x1C6F35D9: TImage::Open(char const*, TImage::EImageFileTypes) (in /home/Rabbitus/ROOT/root/lib/libGraf.so)
==3401==    by 0x1D0813CF: TGPicturePool::GetPicture(char const*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3401==    by 0x1D0113C8: TGClient::GetPicture(char const*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3401==    by 0x1D05F178: TGLVEntry::TGLVEntry(TGWindow const*, TGPicture const*, TGPicture const*, TGString*, TGString**, EListViewMode, unsigned, unsigned long) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3401==    by 0x1D045846: TGFileItem::TGFileItem(TGWindow const*, TGPicture const*, TGPicture const*, TGPicture const*, TGPicture const*, TGString*, int, long long, int, int, EListViewMode, unsigned, unsigned long) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3401==    by 0x1D04627C: TGFileContainer::AddFile(char const*, TGPicture const*, TGPicture const*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3401== 
==3401== Use of uninitialised value of size 4
==3401==    at 0x1EC3D4D9: convert_xpm_scanline (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3401==    by 0x1EC2793B: xpm_file2ASImage (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3401==    by 0x1EC27A2C: xpm2ASImage (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3401==    by 0x1EC29BD2: file2ASImage_extra (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3401==    by 0x1EC29E0E: file2ASImage (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3401==    by 0x1EBE86D7: TASImage::ReadImage(char const*, TImage::EImageFileTypes) (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3401==    by 0x1C6F35D9: TImage::Open(char const*, TImage::EImageFileTypes) (in /home/Rabbitus/ROOT/root/lib/libGraf.so)
==3401==    by 0x1D0813CF: TGPicturePool::GetPicture(char const*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3401==    by 0x1D0113C8: TGClient::GetPicture(char const*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3401==    by 0x1D05F178: TGLVEntry::TGLVEntry(TGWindow const*, TGPicture const*, TGPicture const*, TGString*, TGString**, EListViewMode, unsigned, unsigned long) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3401==    by 0x1D045846: TGFileItem::TGFileItem(TGWindow const*, TGPicture const*, TGPicture const*, TGPicture const*, TGPicture const*, TGString*, int, long long, int, int, EListViewMode, unsigned, unsigned long) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3401==    by 0x1D04627C: TGFileContainer::AddFile(char const*, TGPicture const*, TGPicture const*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)

3, Menu->Tools->Browser (complete output is attached “valgrind_output_Browser.txt”):

==3424== Conditional jump or move depends on uninitialised value(s)
==3424==    at 0x1EC3D4D4: convert_xpm_scanline (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3424==    by 0x1EC2793B: xpm_file2ASImage (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3424==    by 0x1EC27A2C: xpm2ASImage (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3424==    by 0x1EC29BD2: file2ASImage_extra (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3424==    by 0x1EC29E0E: file2ASImage (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3424==    by 0x1EBE86D7: TASImage::ReadImage(char const*, TImage::EImageFileTypes) (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3424==    by 0x1C6F35D9: TImage::Open(char const*, TImage::EImageFileTypes) (in /home/Rabbitus/ROOT/root/lib/libGraf.so)
==3424==    by 0x1D0813CF: TGPicturePool::GetPicture(char const*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D0113C8: TGClient::GetPicture(char const*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D05F178: TGLVEntry::TGLVEntry(TGWindow const*, TGPicture const*, TGPicture const*, TGString*, TGString**, EListViewMode, unsigned, unsigned long) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D045064: TGFileItem::TGFileItem(TGWindow const*, TGPicture const*, TGPicture const*, TGPicture const*, TGPicture const*, TGString*, int, long long, int, int, EListViewMode, unsigned, unsigned long) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D0BB653: TRootObjItem::TRootObjItem(TGWindow const*, TGPicture const*, TGPicture const*, TGString*, TObject*, TClass*, EListViewMode) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424== 
==3424== Use of uninitialised value of size 4
==3424==    at 0x1EC3D4D9: convert_xpm_scanline (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3424==    by 0x1EC2793B: xpm_file2ASImage (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3424==    by 0x1EC27A2C: xpm2ASImage (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3424==    by 0x1EC29BD2: file2ASImage_extra (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3424==    by 0x1EC29E0E: file2ASImage (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3424==    by 0x1EBE86D7: TASImage::ReadImage(char const*, TImage::EImageFileTypes) (in /home/Rabbitus/ROOT/root/lib/libASImage.so)
==3424==    by 0x1C6F35D9: TImage::Open(char const*, TImage::EImageFileTypes) (in /home/Rabbitus/ROOT/root/lib/libGraf.so)
==3424==    by 0x1D0813CF: TGPicturePool::GetPicture(char const*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D0113C8: TGClient::GetPicture(char const*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D05F178: TGLVEntry::TGLVEntry(TGWindow const*, TGPicture const*, TGPicture const*, TGString*, TGString**, EListViewMode, unsigned, unsigned long) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D045064: TGFileItem::TGFileItem(TGWindow const*, TGPicture const*, TGPicture const*, TGPicture const*, TGPicture const*, TGString*, int, long long, int, int, EListViewMode, unsigned, unsigned long) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D0BB653: TRootObjItem::TRootObjItem(TGWindow const*, TGPicture const*, TGPicture const*, TGString*, TObject*, TClass*, EListViewMode) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424== 
==3424== Conditional jump or move depends on uninitialised value(s)
==3424==    at 0x1D05E41C: TGLVEntry::DrawCopy(unsigned long, int, int) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D00F0F9: TGContainer::DrawRegion(int, int, unsigned, unsigned) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D00AA3E: TGViewPort::HandleConfigureNotify(Event_t*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D0370F7: TGFrame::HandleEvent(Event_t*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D011BB0: TGClient::HandleEvent(Event_t*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D011C32: TGClient::ProcessOneEvent() (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D011CE9: TGClient::HandleInput() (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D011D23: TGInputHandler::Notify() (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1BB9D955: TUnixSystem::DispatchOneEvent(bool) (in /home/Rabbitus/ROOT/root/lib/libCore.so)
==3424==    by 0x1BAB63B7: TSystem::InnerLoop() (in /home/Rabbitus/ROOT/root/lib/libCore.so)
==3424==    by 0x1BAB635D: TSystem::Run() (in /home/Rabbitus/ROOT/root/lib/libCore.so)
==3424==    by 0x1BA374EA: TApplication::Run(bool) (in /home/Rabbitus/ROOT/root/lib/libCore.so)
==3424== 
==3424== Invalid read of size 4
==3424==    at 0x1D05E43E: TGLVEntry::DrawCopy(unsigned long, int, int) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D00F0F9: TGContainer::DrawRegion(int, int, unsigned, unsigned) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D00AA3E: TGViewPort::HandleConfigureNotify(Event_t*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D0370F7: TGFrame::HandleEvent(Event_t*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D011BB0: TGClient::HandleEvent(Event_t*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D011C32: TGClient::ProcessOneEvent() (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D011CE9: TGClient::HandleInput() (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D011D23: TGInputHandler::Notify() (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1BB9D955: TUnixSystem::DispatchOneEvent(bool) (in /home/Rabbitus/ROOT/root/lib/libCore.so)
==3424==    by 0x1BAB63B7: TSystem::InnerLoop() (in /home/Rabbitus/ROOT/root/lib/libCore.so)
==3424==    by 0x1BAB635D: TSystem::Run() (in /home/Rabbitus/ROOT/root/lib/libCore.so)
==3424==    by 0x1BA374EA: TApplication::Run(bool) (in /home/Rabbitus/ROOT/root/lib/libCore.so)
==3424==  Address 0x1E5B6D8C is 0 bytes after a block of size 12 alloc'd
==3424==    at 0x1B9095DA: operator new[](unsigned) (vg_replace_malloc.c:138)
==3424==    by 0x1D05E800: TGListView::SetHeaders(int) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D0B89F7: TRootIconBox::SetObjHeaders() (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D0BCEB0: TRootIconBox::AddObjItem(char const*, TObject*, TClass*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D0BD47C: TRootBrowser::AddToBox(TObject*, char const*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1D0BD781: TRootBrowser::Add(TObject*, char const*, int) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1BA414A8: TBrowser::Add(TObject*, char const*, int) (in /home/Rabbitus/ROOT/root/lib/libCore.so)
==3424==    by 0x1BA9DEF5: TROOT::Browse(TBrowser*) (in /home/Rabbitus/ROOT/root/lib/libCore.so)
==3424==    by 0x1D0BDE07: TRootBrowser::BrowseObj(TObject*) (in /home/Rabbitus/ROOT/root/lib/libGui.so)
==3424==    by 0x1BA41673: TBrowser::Create(TObject*) (in /home/Rabbitus/ROOT/root/lib/libCore.so)
==3424==    by 0x1BA420F1: TBrowser::TBrowser(char const*, char const*) (in /home/Rabbitus/ROOT/root/lib/libCore.so)
==3424==    by 0x8053A77: MyFrame::DoMenu(int) (MyGui.cxx:181)

Thank you in advance for your help.

Best regards
Christian
valgrind_output_Open.txt (7.26 KB)
valgrind_output_Exit.txt (15.3 KB)
MyGui4FC4.tar.gz (10.8 KB)

Could you send an example of a session (script) using your classes?
I do not see any problem reported by valgring when using TBrowser.

Rene

Dear Rene

The output for TBrowser is in the file *.tar.gz since it seems that I can only attach three files.

However, I have now created a macro “MyGui.C” which I attach together with the output of valgrind for this macro.
The valgrind output shows the menu actions File->Open, Tools->Browser and File->Exit as indicated in the file.
It seems that valgrind reports the same messages for this macro.

Thank you for your help.
Best regards
Christian
MyGui.C (26.1 KB)
valgrind_output_root.txt (62.4 KB)