|
From: <Bor...@pd...> - 2003-08-05 07:25:07
|
Hello everybody,
The following programm causes a core:
int main( int argc, char** argv )
{
int *a = NULL;
int b = *a;
return 0;
}
Valgrind output:
==26211== Memcheck, a.k.a. Valgrind, a memory error detector for x86-linux.
==26211== Copyright (C) 2002-2003, and GNU GPL'd, by Julian Seward.
==26211== Using valgrind-20030725, a program supervision framework for
x86-linux.
==26211== Copyright (C) 2000-2003, and GNU GPL'd, by Julian Seward.
==26211== Estimated CPU clock rate is 699 MHz
==26211== For more details, rerun with: -v
==26211==
==26211== Invalid read of size 4
==26211== at 0x804844A: main (speicher_test.cc:23)
==26211== by 0x8048340: (within /home/benders/val2/tst/a.out)
==26211== 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 it's
self.
sincerely Borg Enders
|
|
From: Nicholas N. <nj...@ca...> - 2003-08-05 08:07:47
|
On Tue, 5 Aug 2003 Bor...@pd... wrote:
> The following programm causes a core:
> int main( int argc, char** argv )
> {
> int *a = NULL;
>
> int b = *a;
>
> return 0;
> }
>
> Valgrind output:
> ==26211== Memcheck, a.k.a. Valgrind, a memory error detector for x86-linux.
> ==26211== Copyright (C) 2002-2003, and GNU GPL'd, by Julian Seward.
> ==26211== Using valgrind-20030725, a program supervision framework for
> x86-linux.
> ==26211== Copyright (C) 2000-2003, and GNU GPL'd, by Julian Seward.
> ==26211== Estimated CPU clock rate is 699 MHz
> ==26211== For more details, rerun with: -v
> ==26211==
> ==26211== Invalid read of size 4
> ==26211== at 0x804844A: main (speicher_test.cc:23)
> ==26211== by 0x8048340: (within /home/benders/val2/tst/a.out)
> ==26211== 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 it's
> self.
Really? What do you think would be the right way to handle this problem
correctly?
N
|
|
From: Tom H. <th...@cy...> - 2003-08-05 08:10:17
|
In message <E8C...@fs...>
Borg Enders <Bor...@pd...> wrote:
> I think valgrind, should handle this problem correctly and not core
> by it's self.
But valgrind didn't core, your program did. You read invalid
memory by reading through a null pointer. Valgrind warned you
what your program was about to do, then your program did it
and suffered the consequences.
To be honest I'm not quite sure what you are suggesting - that
valgrind should fake up any read that it thinks is questionable
and return some dummy value?
Tom
--
Tom Hughes (th...@cy...)
Software Engineer, Cyberscience Corporation
http://www.cyberscience.com/
|
|
From: Igmar P. <mai...@jd...> - 2003-08-05 13:42:30
|
> The following programm causes a core:
> int main( int argc, char** argv )
> {
> int *a = NULL;
>
> int b = *a;
>
> return 0;
> }
It does. It should.
> Valgrind output:
> ==26211== Memcheck, a.k.a. Valgrind, a memory error detector for x86-linux.
> ==26211== Copyright (C) 2002-2003, and GNU GPL'd, by Julian Seward.
> ==26211== Using valgrind-20030725, a program supervision framework for
> x86-linux.
> ==26211== Copyright (C) 2000-2003, and GNU GPL'd, by Julian Seward.
> ==26211== Estimated CPU clock rate is 699 MHz
> ==26211== For more details, rerun with: -v
> ==26211==
> ==26211== Invalid read of size 4
> ==26211== at 0x804844A: main (speicher_test.cc:23)
> ==26211== by 0x8048340: (within /home/benders/val2/tst/a.out)
> ==26211== 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 it's
> self.
Valgrind is a part of your apps's addresspace. Valgrind doesn't core, your
app does. The current behaviour is correct, I can't think of any reason
to change it.
Igmar
|