valgrind:无法找到valgrind检测到的错误

时间:2014-12-19 13:59:54

标签: c++ memory-leaks valgrind

valgrind检测到我的C ++代码中的错误,但无法判断错误发生在哪一行。以下是valgrind的报告:

==11757== HEAP SUMMARY:
==11757==     in use at exit: 120 bytes in 1 blocks
==11757==   total heap usage: 66,334 allocs, 66,333 frees, 137,141,930 bytes allocated
==11757== 
==11757== 120 bytes in 1 blocks are definitely lost in loss record 1 of 1
==11757==    at 0x4C274A8: malloc (vg_replace_malloc.c:236)
==11757==    by 0x8097788: getdelim (iogetdelim.c:68)
==11757==    by 0xFAB5EB2: ??? (in /lib/libselinux.so.1)
==11757==    by 0xFABE465: ??? (in /lib/libselinux.so.1)
==11757==    by 0xFAAE2D2: ??? (in /lib/libselinux.so.1)
==11757==    by 0x7FF0009D6: ???
==11757==    by 0x6B72776164642F6F: ???
==11757==    by 0x6C6F6F542F75542E: ???
==11757==    by 0x4846472F7374696A: ???
==11757==    by 0x474F4846472F474E: ???
==11757==    by 0x3100742D006E6C2D: ???
==11757==    by 0x30303200732CFF: ???
==11757== 
==11757== LEAK SUMMARY:
==11757==    definitely lost: 120 bytes in 1 blocks
==11757==    indirectly lost: 0 bytes in 0 blocks
==11757==      possibly lost: 0 bytes in 0 blocks
==11757==    still reachable: 0 bytes in 0 blocks
==11757==         suppressed: 0 bytes in 0 blocks
==11757== 
==11757== For counts of detected and suppressed errors, rerun with: -v
==11757== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 4 from 4)

由于我的代码太长,我无法在此发布。从报告中,有一个块不同意。但是valgrind并没有告诉我代码中的哪一行分配了那个内存,这真是奇怪。有什么帮助吗? 注意:我在编译代码时在Makefile中添加了标志-g。如果您需要更多信息,请与我们联系 我的Makefile

# source files. 
SRC = main.cpp Fonix.cpp TraceDetect.cpp ImageT.cpp
OBJ = $(SRC:.cpp=.o)
OUT = out.ln

INCS_DIR = /vol/fonix/enterprise/include/
LIBS_DIR = /vol/fonix/enterprise/lib

# include directories
INCLUDES = -I$(INCS_DIR)

# C++ compiler flags (-g -O2 -Wall)
CCFLAGS = -g -fPIC -fopenmp -Wall -O0

# compiler
CCC = g++

# library paths
LIBS = -L$(LIBS_DIR) -lopencv_imgproc -lopencv_calib3d -lopencv_video -lopencv_features2d -lopencv_ml  -lopencv_objdetect -lopencv_gpu  -lopencv_flann -lopencv_contrib -lopencv_legacy -lopencv_highgui -lopencv_core -lswscale -lswresample -lavdevice -lavformat -lavcodec -lavutil -lz -lbz2 -lpthread -lsuperlu_4.3 -lblas

.SUFFIXES: .cpp

default: $(OUT)

.cpp.o:
    $(CCC) $(INCLUDES) $(CCFLAGS) -D_DEBUG=1 -c $< -o $@

$(OUT): $(OBJ)
    $(CCC) $(OBJ) $(LIBS) $(CCFLAGS) -o $@

clean:
    rm -f $(OBJ) $(OUT) Makefile.bak 

0 个答案:

没有答案