2011-11-16 1 views
1

심지어 의도적 인 메모리 누수 Valgrind의 도입 후에는 보여줍니다Valgrind의가 인스트루먼트되지 않은 : "총 힙 사용 : 0 allocs, 0 해방, 0 바이트 할당"

==13483== HEAP SUMMARY: 
==13483==  in use at exit: 0 bytes in 0 blocks 
==13483== total heap usage: 0 allocs, 0 frees, 0 bytes allocated 
==13483== 
==13483== All heap blocks were freed -- no leaks are possible 

실행 파일이 G ++ 4.1.2과 함께 컴파일 4.6.2로 :

g++ -ftemplate-depth-128 -O0 -fno-inline -Wall -pedantic -g -pthread -Wno-long-long -Wno-uninitialized <snipped definitions and include directives from the build system> 

나는 Valgrind의 3.5.0와 같은 3.6.1으로 시도했다 : 일 이내

valgrind --leak-check=full --undef-value-errors=no --show-reachable=yes <executable args> 

도서관의 전자 프레임 워크는 내가 간단한 테스트 케이스를 사용하고, 일하고 있어요 : 분명히

#include "pwiz/utility/misc/Std.hpp" 
#include "pwiz/utility/misc/Filesystem.hpp" 
#include "pwiz/data/identdata/IdentDataFile.hpp" 

using namespace pwiz::cv; 
using namespace pwiz::data; 
using namespace pwiz::identdata; 
using namespace pwiz::util; 

int main(int argc, char** argv) 
{ 
    vector<string> args(argv+1, argv+argc); 
    BOOST_FOREACH(const bfs::path& filename, args) 
    { 
     // intentional memory leak 
     IdentDataFile* idp = new IdentDataFile(filename.string()); 
     IdentDataFile& id = *idp; 
     cout << filename.string() << " " 
      << id.analysisCollection.spectrumIdentification[0]->activityDate << " " 
      << id.analysisCollection.spectrumIdentification[0]->spectrumIdentificationListPtr->spectrumIdentificationResult.size() 
      << "\n"; 
    } 
    return 0; 
} 

나는 다른 사람이를 컴파일 할 수 있기를 기대하지 않는다,하지만 어쨌든 나는 도서관에 대해 뭔가 의심 그 때문에 valgrind가 넘어져서 더 간단한 테스트 케이스는 무의미합니다. 그리고 내가 Valgrind 실행 중에 cout 출력을 얻기 때문에 for 루프가 실행되고 있다는 것을 알고 있습니다. 더 단순화하지 않고 어떻게 디버깅 할 수 있습니까?

+0

어떤 종류의 누출을 생산하고 있습니까? – cnicutar

+0

의도적 인 누출은 해당하는 '삭제'가없는 간단한 '새로운'문입니다. –

+0

소스를 제공 할 수 있습니까? 거기에 커스텀'연산자 new()가있을 수 있습니까? –

답변

2

실제로 링커 옵션으로 요약됩니다. 나는 -static으로 컴파일하고 있었으므로 valgrind는 자신의 malloc 구현을 대체 할 기회가 없었습니다. 불행한 그 valgrind 적어도 이것에 대해 경고하지 않습니다!