From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2541 invoked by alias); 29 Jun 2006 09:02:07 -0000 Received: (qmail 2394 invoked by uid 22791); 29 Jun 2006 09:02:02 -0000 X-Spam-Check-By: sourceware.org Received: from mail6.tpgi.com.au (HELO mail6.tpgi.com.au) (203.12.160.113) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 29 Jun 2006 09:01:58 +0000 Received: from nono.tps.com.au (203-206-169-155.perm.iinet.net.au [203.206.169.155]) (authenticated bits=0) by mail6.tpgi.com.au (envelope-from sjclarke@tpg.com.au) (8.13.6/8.13.6) with ESMTP id k5T91qPi005453 for ; Thu, 29 Jun 2006 19:01:55 +1000 Subject: mudflapth not working From: Stuart Clarke To: gcc-bugs@gcc.gnu.org Content-Type: text/plain Date: Thu, 29 Jun 2006 09:36:00 -0000 Message-Id: <1151571699.17989.31.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.6.2 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-06/txt/msg02484.txt.bz2 List-Id: Hi all, First submission to this list, so go easy on me. I've the following file (temp.cc): #include #include #include 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