c++ - Valgrind results of a "segmentation fault" program -
my program (./a.out) encountered segmentation fault, use valgrind check if can find @ line of code program corrupts. , got following output, cannot understand then. me, suspicious line of output ==17967== address 0x20687cf80 0 bytes inside block of size 16 alloc'd, line means address 0x20687cf80 not propoerly allocated memory block? can resolve problem.
i using 64-bit linux 64gb ram.
[root@gpu bloomfilterandhashtable]# valgrind --tool=memcheck --leak-check=full ./a.out /mnt/disk2/experiments/two_stage_bloom_filter/test/10_10.txt /mnt/disk2/experiments/10m_worstcase_trace/w_10_10.trace 24 ==17967== memcheck, memory error detector ==17967== copyright (c) 2002-2010, , gnu gpl'd, julian seward et al. ==17967== using valgrind-3.6.1 , libvex; rerun -h copyright info ==17967== command: ./a.out /mnt/disk2/experiments/two_stage_bloom_filter/test/10_10.txt /mnt/disk2/experiments/10m_worstcase_trace/w_10_10.trace 24 ==17967== 9998797 prefixes loaded! //output of program ==17967== warning: set address range perms: large range [0x4201a040, 0x6f423220) (defined) ==17967== warning: set address range perms: large range [0x9c834040, 0x20687cf40) (undefined) insertion cost time(us): 173168519 9998797 17.318935 0.057740 //output of program ==17967== warning: set address range perms: large range [0x23647d040, 0x25647d040) (defined) trace loaded! //output of program lookup cost time(us): 5728767367 67108864 85.365286 0.011714 //output of program ==17967== mismatched free() / delete / delete [] ==17967== @ 0x4a055fe: free (vg_replace_malloc.c:366) ==17967== 0x401b13: hash_table_delete(bloomfilter*, char*) (bloomfilterandhashtable.cpp:503) ==17967== 0x402212: main (bloomfilterandhashtable.cpp:687) ==17967== address 0x20687cf80 0 bytes inside block of size 16 alloc'd ==17967== @ 0x4a05f97: operator new(unsigned long) (vg_replace_malloc.c:261) ==17967== 0x40146d: hash_table_insert(char*, int, bloomfilter*) (bloomfilterandhashtable.cpp:293) ==17967== 0x401dd5: main (bloomfilterandhashtable.cpp:597) ==17967== delete succeeded! //output of program deletion cost time(us): 178048113 9998797 17.806953 0.056158 //output of program ==17967== warning: set address range perms: large range [0x23647d030, 0x25647d050) (noaccess) --17967:0:aspacem valgrind: fatal: vg_n_segments low. --17967:0:aspacem increase , rebuild. exiting now. [root@gpu bloomfilterandhashtable]#
the "suspicious" output ==17967== address 0x20687cf80 0 bytes inside block of size 16 alloc'd means, there allocated block of memory, 16 bytes in size. address 0x20687cf80 address of first byte of block (i.e. it's address of whole block). line tell details memory block involved in whole warning.
the warning "mismatched free()". following lines show free
called:
==17967== @ 0x4a055fe: free (vg_replace_malloc.c:366)
==17967== by 0x401b13: hash_table_delete(bloomfilter*, char*) (bloomfilterandhashtable.cpp:503)
meaning, hash_table_delete
calls free()
. now, why valgrind think mismatch? because address of memory block gets freed (0x20687cf80) allocated operator new
, called hash_table_insert
:
==17967== @ 0x4a05f97: operator new(unsigned long) (vg_replace_malloc.c:261)
==17967== by 0x40146d: hash_table_insert(char*, int, bloomfilter*) (bloomfilterandhashtable.cpp:293)
this suspicious. if source of error problem, should fix anyways.