Skip to content
Snippets Groups Projects
  • Mark Jones's avatar
    085928d1
    Add "+1" to length when using new char[] · 085928d1
    Mark Jones authored
    Found when doing valgrind --tool=memcheck --track-origins=yes --leak-check=full hcana
    Return errors like below
    ==14467== Invalid write of size 1
    ==14467==    at 0x4A0794F: __GI_strcpy (mc_replace_strmem.c:313)
    ==14467==    by 0x57137A3: THcHodoscope::Setup(char const*, char const*) (THcHodoscope.cxx:112)
    ==14467==    by 0x5713A7E: THcHodoscope::Init(TDatime const&) (THcHodoscope.cxx:142)
    ==14467==    by 0x4D38C29: THaApparatus::Init(TDatime const&) (THaApparatus.C:193)
    ==14467==    by 0x4D67E57: THaAnalyzer::InitModules(TList const*, TDatime&, int, char const*) (THaAnalyzer.C:433)
    ==14467==    by 0x4D68B1F: THaAnalyzer::DoInit(THaRunBase*) (THaAnalyzer.C:667)
    ==14467==    by 0x4D68126: THaAnalyzer::Init(THaRunBase*) (THaAnalyzer.C:467)
    ==14467==    by 0x4D6B31A: THaAnalyzer::Process(THaRunBase*) (THaAnalyzer.C:1289)
    ==14467==    by 0x4E21E97: G__haDict_704_0_6(G__value*, char const*, G__param*, int) (haDict.C:23491)
    ==14467==    by 0x6DB6148: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /u/apps/root/5.34.13/root/lib/libCint.so.5.34)
    ==14467==    by 0x6E5A3A0: G__execute_call (in /u/apps/root/5.34.13/root/lib/libCint.so.5.34)
    ==14467==    by 0x6E5B201: G__call_cppfunc (in /u/apps/root/5.34.13/root/lib/libCint.so.5.34)
    ==14467==  Address 0xd7636a2 is 0 bytes after a block of size 2 alloc'd
    ==14467==    at 0x4A0674C: operator new[](unsigned long) (vg_replace_malloc.c:305)
    ==14467==    by 0x5713757: THcHodoscope::Setup(char const*, char const*) (THcHodoscope.cxx:111)
    ==14467==    by 0x5713A7E: THcHodoscope::Init(TDatime const&) (THcHodoscope.cxx:142)
    ==14467==    by 0x4D38C29: THaApparatus::Init(TDatime const&) (THaApparatus.C:193)
    ==14467==    by 0x4D67E57: THaAnalyzer::InitModules(TList const*, TDatime&, int, char const*) (THaAnalyzer.C:433)
    ==14467==    by 0x4D68B1F: THaAnalyzer::DoInit(THaRunBase*) (THaAnalyzer.C:667)
    ==14467==    by 0x4D68126: THaAnalyzer::Init(THaRunBase*) (THaAnalyzer.C:467)
    ==14467==    by 0x4D6B31A: THaAnalyzer::Process(THaRunBase*) (THaAnalyzer.C:1289)
    ==14467==    by 0x4E21E97: G__haDict_704_0_6(G__value*, char const*, G__param*, int) (haDict.C:23491)
    ==14467==    by 0x6DB6148: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /u/apps/root/5
    085928d1
    History
    Add "+1" to length when using new char[]
    Mark Jones authored
    Found when doing valgrind --tool=memcheck --track-origins=yes --leak-check=full hcana
    Return errors like below
    ==14467== Invalid write of size 1
    ==14467==    at 0x4A0794F: __GI_strcpy (mc_replace_strmem.c:313)
    ==14467==    by 0x57137A3: THcHodoscope::Setup(char const*, char const*) (THcHodoscope.cxx:112)
    ==14467==    by 0x5713A7E: THcHodoscope::Init(TDatime const&) (THcHodoscope.cxx:142)
    ==14467==    by 0x4D38C29: THaApparatus::Init(TDatime const&) (THaApparatus.C:193)
    ==14467==    by 0x4D67E57: THaAnalyzer::InitModules(TList const*, TDatime&, int, char const*) (THaAnalyzer.C:433)
    ==14467==    by 0x4D68B1F: THaAnalyzer::DoInit(THaRunBase*) (THaAnalyzer.C:667)
    ==14467==    by 0x4D68126: THaAnalyzer::Init(THaRunBase*) (THaAnalyzer.C:467)
    ==14467==    by 0x4D6B31A: THaAnalyzer::Process(THaRunBase*) (THaAnalyzer.C:1289)
    ==14467==    by 0x4E21E97: G__haDict_704_0_6(G__value*, char const*, G__param*, int) (haDict.C:23491)
    ==14467==    by 0x6DB6148: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /u/apps/root/5.34.13/root/lib/libCint.so.5.34)
    ==14467==    by 0x6E5A3A0: G__execute_call (in /u/apps/root/5.34.13/root/lib/libCint.so.5.34)
    ==14467==    by 0x6E5B201: G__call_cppfunc (in /u/apps/root/5.34.13/root/lib/libCint.so.5.34)
    ==14467==  Address 0xd7636a2 is 0 bytes after a block of size 2 alloc'd
    ==14467==    at 0x4A0674C: operator new[](unsigned long) (vg_replace_malloc.c:305)
    ==14467==    by 0x5713757: THcHodoscope::Setup(char const*, char const*) (THcHodoscope.cxx:111)
    ==14467==    by 0x5713A7E: THcHodoscope::Init(TDatime const&) (THcHodoscope.cxx:142)
    ==14467==    by 0x4D38C29: THaApparatus::Init(TDatime const&) (THaApparatus.C:193)
    ==14467==    by 0x4D67E57: THaAnalyzer::InitModules(TList const*, TDatime&, int, char const*) (THaAnalyzer.C:433)
    ==14467==    by 0x4D68B1F: THaAnalyzer::DoInit(THaRunBase*) (THaAnalyzer.C:667)
    ==14467==    by 0x4D68126: THaAnalyzer::Init(THaRunBase*) (THaAnalyzer.C:467)
    ==14467==    by 0x4D6B31A: THaAnalyzer::Process(THaRunBase*) (THaAnalyzer.C:1289)
    ==14467==    by 0x4E21E97: G__haDict_704_0_6(G__value*, char const*, G__param*, int) (haDict.C:23491)
    ==14467==    by 0x6DB6148: Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) (in /u/apps/root/5
THcDC.cxx 38.41 KiB