molpro / sjef

Simple Job Execution Framework
Other
2 stars 4 forks source link

valgrind warnigs in expand_path (sjef built with gnu, boost with apple compilers) #47

Closed pjknowles closed 2 years ago

pjknowles commented 2 years ago

In GitLab by @klauspdoll on Apr 29, 2022, 13:54

This may be related to #51 .

version 1.17.2

build with gnu compilers:

CXX=g++-10 CC=gcc-10 cmake .. -DCMAKE_BUILD_TYPE=Debug
make

basic command "status" crashes:

program/sjef status ~/klaustest/h2o.molpro/
sjef(9043,0x7fff8b2ae380) malloc: *** error for object 0x7fc7afc02e0a: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

with debugger, relevant output:

lldb program/sjef
(lldb) run status ~/klaustest/h2o.molpro/

terminate called after throwing an instance of 'std::runtime_error'
  what():  Cannot deduce project suffix for "/Users/molpro/klaustest/h2o.molpro/" with default suffix ""
Process 9046 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00007fff52c28b66 libsystem_kernel.dylib`__pthread_kill + 10
libsystem_kernel.dylib`__pthread_kill:
->  0x7fff52c28b66 <+10>: jae    0x7fff52c28b70            ; <+20>
    0x7fff52c28b68 <+12>: movq   %rax, %rdi
    0x7fff52c28b6b <+15>: jmp    0x7fff52c1fae9            ; cerror_nocancel
    0x7fff52c28b70 <+20>: retq   
Target 0: (sjef) stopped.

valgrind, relevant warnings :

valgrind program/sjef status ~/klaustest/h2o.molpro/

==9053==  Address 0x101740e60 is 16 bytes before a block of size 19 alloc'd
==9053==    at 0x10065F086: malloc (in /usr/local/Cellar/valgrind/HEAD-adaae87/lib/valgrind/vgpreload_memcheck-amd64-darwin.so)
==9053==    by 0x10069C314: operator new(unsigned long) (in /usr/local/Cellar/gcc/10.1.0/lib/gcc/10/libstdc++.6.dylib)
==9053==    by 0x100093748: TCLAP::Arg::Arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, bool, TCLAP::Visitor*) (Arg.h:469)
==9053==    by 0x100095476: TCLAP::SwitchArg::SwitchArg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, TCLAP::Visitor*) (SwitchArg.h:151)
==9053==    by 0x10009B5AD: sjef_program (sjef-program.cpp:97)
==9053==    by 0x100001D53: main (main.cpp:4)

==9053== Conditional jump or move depends on uninitialised value(s)
==9053==    at 0x100676437: boost::filesystem::path::filename() const (in /usr/local/Cellar/boost/1.71.0/lib/libboost_filesystem.dylib)
==9053==    by 0x100675BDC: boost::filesystem::path::extension() const (in /usr/local/Cellar/boost/1.71.0/lib/libboost_filesystem.dylib)
==9053==    by 0x1000276EA: sjef::expand_path(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (sjef.cpp:1684)
==9053==    by 0x100011C33: sjef::Project::get_project_suffix(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const (sjef.cpp:255)
==9053==    by 0x10000CC1D: sjef::Project::Project(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&, sjef::Project const*) (sjef.cpp:93)
==9053==    by 0x10009C13A: sjef_program (sjef-program.cpp:133)
==9053==    by 0x100001D53: main (main.cpp:4)_

==9053== Conditional jump or move depends on uninitialised value(s)
==9053==    at 0x100676437: boost::filesystem::path::filename() const (in /usr/local/Cellar/boost/1.71.0/lib/libboost_filesystem.dylib)
==9053==    by 0x100675BDC: boost::filesystem::path::extension() const (in /usr/local/Cellar/boost/1.71.0/lib/libboost_filesystem.dylib)
==9053==    by 0x100011C65: sjef::Project::get_project_suffix(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const (sjef.cpp:255)
==9053==    by 0x10000CC1D: sjef::Project::Project(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&, sjef::Project const*) (sjef.cpp:93)
==9053==    by 0x10009C13A: sjef_program (sjef-program.cpp:133)
==9053==    by 0x100001D53: main (main.cpp:4)
pjknowles commented 2 years ago

In GitLab by @klauspdoll on Apr 29, 2022, 13:54

marked this issue as related to #51

pjknowles commented 2 years ago

In GitLab by @klauspdoll on Apr 29, 2022, 14:29

No failure with apple compilers.

This issue is a spin off from #51 , as I ran the command

program/sjef status ~/klaustest/h2o.molpro

with valgrind. Essentially, valgrind warns about:

sjef-program.cpp:97

which is

m_recent_projects_file = expand_path(recent_projects_directory + "/projects");

sjef.cpp:1684

which is

if (fs::path{text}.extension().native() != std::string{"."} + suffix and !suffix.empty())

pjknowles commented 2 years ago

In GitLab by @klauspdoll on May 10, 2022, 13:36

As seen in #51, this crash vanishes when boost and sjef are both built with gnu-compilers.