[valgrind] 常见错误提示
2008-07-20 22:01:39| 分类:
valgrind
| 标签:
|举报
|字号大中小 订阅
Syscall param write(buf) contains uninitialised or unaddressable byte(s)
write() 多写了 one byte
------------------------------------
int main()
{
char buf[80];
strcpy(buf, "abcdef");
write(1, buf, 8);
return 0;
}
Conditional jump or move depends on uninitialised value(s)
变量 i 未初始化
------------------------------------
int main()
{
int i;
if ( i == 3 )
printf("ok\n");
else
printf("fail\n");
return 0;
}
==17774== Syscall param write(buf) contains uninitialised or unaddressable byte(s)
==17774== at 0x3C0FA32F: (within /lib/libc.so.6)
==17774== by 0x8048475: _start (in /home/kasicass/sandbox/valgrind/a.out)
==17774== by 0x0: ???
==17774== Address 0x3C122026 is 2 bytes inside a block of size 10 alloc'd
==17774== at 0x3C038183: malloc (in /usr/local/lib/valgrind/vgpreload_memcheck.so)
==17774== by 0x8048551: main (test.c:6)
给 write() 的 p 中,只有 2byte valid。
----------------------------------------------
int main()
{
char *p = malloc(10);
p[0] = 'a';
p[1] = 'b';
write(1, p, 10);
return 0;
}
评论这张
转发至微博
转发至微博
评论