This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
mudflapth not working
- From: Stuart Clarke <sjclarke at tpg dot com dot au>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 29 Jun 2006 19:01:39 +1000
- Subject: mudflapth not working
Hi all,
First submission to this list, so go easy on me. I've the following
file (temp.cc):
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
int foo_static[] = {0, 0};
void* run(void* arg)
{
int foo[] = {0, 0};
printf("foo[2]: %d\r\n", foo[2]);
printf("foo_static[2]: %d\r\n", foo_static[2]);
}
int main(void)
{
pthread_t thread;
pthread_attr_t attributes;
pthread_attr_init(&attributes);
pthread_create(&thread, &attributes, &run, 0);
for (;;) {
sleep(1);
}
return 0;
}
And I conduct the following transaction with my computer:
beef@nono:~$ set | fgrep MUDFLAP
MUDFLAP_OPTIONS='-mode-check --viol-segv'
beef@nono:~$ g++ -fmudflapth -fmudflap temp.cc -lmudflapth -lpthread
beef@nono:~$ ./a.out
foo[2]: -1209174832
*******
mudflap violation 1 (check/read): time=1151571511.357805 ptr=0x80c9168
size=12
pc=0xb7ec5a30 location=`temp.cc:13 (run)'
/usr/lib/libmudflapth.so.0(__mf_check+0x50) [0xb7ec5a30]
./a.out(_Z3runPv+0x1f0) [0x8048be2]
/usr/lib/libmudflapth.so.0 [0xb7ed3a53]
Nearby object 1: checked region begins 0B into and ends 4B after
mudflap object 0x80ca2e8: name=`temp.cc:6 int foo_static [2]'
bounds=[0x80c9168,0x80c916f] size=8 area=static check=3r/0w liveness=3
alloc time=1151571511.288349 pc=0xb7ec53f0 thread=3083183808
number of nearby objects: 1
Segmentation fault
beef@nono:~$
As you can see, only the indexing of foo_static caused a violation, not
the indexing of foo. If foo were in main()'s stack, however, it would
have caused a violation.
Versions of stuff as follows:
beef@nono:~$ gcc --version
gcc (GCC) 4.1.2 20060613 (prerelease) (Debian 4.1.1-5)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
beef@nono:~$ uname -a
Linux nono 2.6.15.6 #2 Thu Mar 9 17:34:11 EST 2006 i686 GNU/Linux
beef@nono:~$
I've tried to compile 4.1.0 from a GNU mirror, but with the same result.
Can anyone shed some light on this?
Thanks,
Stuart
--
Stuart Clarke <sjclarke@tpg.com.au>