|
From: Xiaoshan S. <xs...@in...> - 2005-04-19 01:24:44
|
hi,everybody
i have tried the valgrind and i see that it is wonderful. i like
it.however,i have a code which obviously access invalidate memory but
valgrind fail to detect it .
the code is :
----------------
include <stdio.h>
int main()
{
char buf[10];
int i;
for(i=0;i<12;i++){
buf[i]=0;
}
}
-------------------
the valgrind reprots no error .
so can valgrind detect error of this kind ??
this is important .so lets see another example :
--------------------
#include <iostream>
#include <string>
using namespace std;
const int ERRLEN=15;
int main()
{
char buf[2];
string str;
char buf2[5];
cin>>str;
for(int i=0;i<ERRLEN;i++){
buf[i]=0x80;
}
cout<<str;
}
---------------------------
while ERRLEN<15 ,no runtime error ,but when ERRLEN>=15 ,segment fault
displayed when run.obviously both have invalidate memory access .the
true cause is not the string's fault but an overwritten of the string's
buffer string .
~
~
|
|
From: Nicholas N. <nj...@cs...> - 2005-04-19 03:06:18
|
On Tue, 19 Apr 2005, Xiaoshan Sun wrote:
> hi,everybody
> i have tried the valgrind and i see that it is wonderful. i like
> it.however,i have a code which obviously access invalidate memory but
> valgrind fail to detect it .
> the code is :
> ----------------
> include <stdio.h>
>
> int main()
> {
> char buf[10];
> int i;
> for(i=0;i<12;i++){
> buf[i]=0;
> }
> }
> -------------------
> the valgrind reprots no error .
> so can valgrind detect error of this kind ??
No. See FAQ 6.2 at http://www.valgrind.org/docs/FAQ/faq.notfound.html
N
|