登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Code@Pig Home

喜欢背着一袋Code傻笑的Pig .. 忧美.欢笑.记忆.忘却 .之. 角落

 
 
 

日志

 
 

[valgrind] 常见错误提示  

2008-07-20 22:01:39|  分类: valgrind |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
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;
}


  评论这张
 
阅读(1042)| 评论(0)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018