转自:http://blog.csdn.net/gatieme/article/details/51959654 (点击有惊喜)
转自:http://blog.sina.com.cn/s/blog_4c98b9600100jq4v.html
Memcheck 工具主要检查下面的程序错误:
使用未初始化的内存 (Use ofuninitialised memory)使用已经释放了的内存(Reading/writing memory after it has been free’d)使用超过malloc分配的内存空间(Reading/writing off the end of malloc’d blocks)对堆栈的非法访问 (Reading/writing inappropriate areas onthe stack)申请的空间是否有释放 (Memory leaks – where pointers tomalloc’d blocks are lost forever)malloc/free/new/delete申请和释放内存的匹配(Mismatched use ofmalloc/new/new [] vs free/delete/delete [])src和dst的重叠(Overlapping src and dst pointers inmemcpy() and related functions)下面是常用的错误输出信息
Conditional jump or move depends on uninitialised value(s) 诊断信息A 程序行为可能与策略预期不一致,请仔细核查! 诊断信息B XXXgz导致的警告,主要是因为机器字节对齐填充了没有初始值的数据导致! 对应两个警告信息,如果是调用XXX_gzip引出的警告,则输出信息B,否则信息A。
Warning: set address range perms: large range 诊断信息 此警告可忽略! 只对应一条信息。
Syscall param *(buf) points to uninitialised byte(s) 诊断信息 请确认此系统函数所使用的参数是否需要初始化! 只对应一条信息。
Invalid read of size * 诊断信息 读取无效内存地址错误! 只对应一条信息。
Process terminating with default action of signal (): dumpingcore 诊断信息 程序执行期间出core! 只对应一条信息。
Use of uninitialised value of size 诊断信息 请确认此内存地址不需要初始化! 只对应一条信息。
* bytes in * blocks are possibly lost in loss record * of* 诊断信息A 内存可能存在泄露! 诊断信息B glibc内部的内存泄露的问题,可以忽略! 对应两条信息,如果发现valgrind警告的调用堆栈出现pthread_creat则返回信息B,否则返回信息A。
(* direct, * indirect) bytes in * blocks are definitely lost inloss record * of * 诊断信息 内存泄露错误! 只对应一条信息。
Invalid write of size 诊断信息 写入无效内存地址错误! 只对应一条信息。
Mismatched free() / delete / delete[] 诊断信息 请确保malloc的内存用free释放,new的内存用delete释放! 只对应一条信息。
Source and destination overlap in cpy(, *) 诊断信息A 致命错误,程序行为不符合策略预期! 诊断信息B 行为未定义,完全依赖glibc的实现,不具有可移植性! 对应两条信息,如果复制的源地址小于目的地址则返回信息A,否则返回信息B。
编译参数中添加选项-g -fno-inline