|
From: <Bor...@pd...> - 2003-08-05 08:53:37
|
Don't get personal. I'am checking for Null-Pointers in my code...all I =
do
here is discuss a hypothetic case.
I think like valgrind works now it's not a well defined behavoiur (one =
term
you could know out of computer science), and all it should do is print
something like the following output:
'Null Pointer access: Write core [c/C]? Stop execution [s/S]? Continue =
on
own risk [r/R]?'
Even a simple message from valgrind like the following would make the
situation clear:
'Your program has caused a memory fault.'=20
After such a message every user should know, that It's his bug and not =
a
bug of valgrind.
So to sum up:
My point is: an "Invalid read" followed by a core makes it not always =
clear
if this is a bug of valgrind or the tested programm. A short message to =
the
user before the core is written would make this situation more clear.
-----Urspr=FCngliche Nachricht-----
Von: Lee Kindness [mailto:lki...@cs...]=20
Gesendet: Dienstag, 5. August 2003 10:40
An: Enders, Borg; val...@li...
Cc: Lee Kindness
Betreff: AW: [Valgrind-users] core for null pointer access
I don't know, but you seem to be missing smething here... Valgrind =
already
IS telling you there is something wrong with your program. It then says
"fair enough" and lets your program dig its own grave. What would you =
want
it do instead?
1. Return some value instead of referencing the memory? What value? =
Your
program after this state will be calculating based on an incorrect =
value.
2. Simply skip the instruction?!
3. Abort execution?
Do you know what the proper way is?
4. Fix your program - it's got no chance of working as-is! YOU should =
be
checking for NULL parameters in your code if they are possible in the
calling chain.
L/
Bor...@pd... writes:
> I think a correct behaviour would be something to ask the user if he
wants > to get a core, wants to end the program, or continue with the
execution > beside the printing of the errortext together with a the =
stack
output.=20
> The way valgrind handles this situation now, seems like a not well
defined > behaviour of valgrind in itself. With the above mentioned =
method,
the user > would be sure, that this is a bug of his program and not =
one of
> valgrind...which is really usefull, when the scenario for the =
Null-Pointer
> Access gets much more complicated than my little example programm. =
For >
example by passing of an NULL pointer as function parameter through =
some >
function calls. If you than only get a core for valgrind, I don't think =
>
every user will see the bug. >=20
> Sincerely Borg Enders
>=20
>=20
> -----Urspr=FCngliche Nachricht-----
> Von: Nicholas Nethercote [mailto:nj...@ca...]=20
> Gesendet: Dienstag, 5. August 2003 10:08
> An: Enders, Borg
> Cc: val...@li...
> Betreff: Re: [Valgrind-users] core for null pointer access
>=20
>=20
> On Tue, 5 Aug 2003 Bor...@pd... wrote:
>=20
> > The following programm causes a core:
> > int main( int argc, char** argv )
> > {
> > int *a =3D NULL;
> >
> > int b =3D *a;
> >
> > return 0;
> > }
> >
> > Valgrind output:
> > =3D=3D26211=3D=3D Memcheck, a.k.a. Valgrind, a memory error =
detector for=20
> > x86-linux. =3D=3D26211=3D=3D Copyright (C) 2002-2003, and GNU =
GPL'd, by Julian=20
> > Seward. =3D=3D26211=3D=3D Using valgrind-20030725, a program =
supervision=20
> > framework for x86-linux. =3D=3D26211=3D=3D Copyright (C) =
2000-2003, and GNU=20
> > GPL'd, by Julian Seward. =3D=3D26211=3D=3D Estimated CPU clock =
rate is 699 MHz
> > =3D=3D26211=3D=3D For more details, rerun with: -v > > =
=3D=3D26211=3D=3D > > =3D=3D26211=3D=3D
Invalid read of size 4
> > =3D=3D26211=3D=3D at 0x804844A: main (speicher_test.cc:23)
> > =3D=3D26211=3D=3D by 0x8048340: (within =
/home/benders/val2/tst/a.out)
> > =3D=3D26211=3D=3D Address 0x0 is not stack'd, malloc'd or =
free'd
> > Memory fault(coredump)
> >
> >
> > I think valgrind, should handle this problem correctly and not =
core by=20
> > it's self.
>=20
> Really? What do you think would be the right way to handle this =
problem
> correctly? >=20
> N
>=20
>=20
> -------------------------------------------------------
> This SF.Net email sponsored by: Free pre-built ASP.NET sites =
including >
Data Reports, E-commerce, Portals, and Forums are available now. > =
Download
today and enter to win an XBOX or Visual Studio .NET. >
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01=
/01
> _______________________________________________
> Valgrind-users mailing list
> Val...@li...
> https://lists.sourceforge.net/lists/listinfo/valgrind-users
|