|
From: ragnar s. <rag...@po...> - 2004-02-18 15:29:03
|
Hi!
In first time for a long time I had to track down a bug manually! :-)
Here is the full example. I get
Segfault when I run it.
valgrind-20030725
gcc 2.95.4
thanks very much for valgrind
/ragge
#include <stdio.h>
void
myquit()
{
printf("myquit()\n");
exit(0);
}
int
main(int argc, char **argv)
{
void (* func)();
func = myquit;
func = 1; /* Introduce bug */
func();
printf("not reachable code\n");
exit(-1);
}
___________________________________________________
Take your business online with Officemaster. Sign up for a free trial today!
http://www.officemaster.net
|
|
From: Nicholas N. <nj...@ca...> - 2004-02-18 16:37:27
|
On Wed, 18 Feb 2004, ragnar sjoberg wrote:
> Segfault when I run it.
>
> #include <stdio.h>
>
> void
> myquit()
> {
> printf("myquit()\n");
> exit(0);
> }
>
> int
> main(int argc, char **argv)
> {
> void (* func)();
> func = myquit;
> func = 1; /* Introduce bug */
> func();
> printf("not reachable code\n");
> exit(-1);
> }
Interestingly, Memcheck spots the error before the seg fault if you use
(AFAICT) any bogus address other than 1. VG_(translate)() isn't getting
called when the code address is 0x1, and so the pre_mem_read with which
Memcheck checks the address isn't occurring -- can anyone suggest a reason
why this might the case? Some artifact of the code cache lookup that
means it erroneously succeeds when searching for address 0x1, maybe?
N
|