Build the following C program with "gcc -fmudflap <program name> -lmudflap":

***
#include <stdlib.h>

int main()
{
        char* crash = (char*)malloc(1);
        crash[1] = 1;
        crash[-1] = 1;
        return 0;
}
***

The output is expected and correct -- 2 violations are reported:

*******
mudflap violation 1 (check/write): time=1155044090.468101 ptr=0x9593589 size=1
pc=0xb7e4326d location=`mudflap_crash.c:6 (main)'
      /usr/lib/libmudflap.so.0(__mf_check+0x3d) [0xb7e4326d]
      ./a.out(main+0x98) [0x804871c]
      /usr/lib/libmudflap.so.0(__wrap_main+0x49) [0xb7e42d29]
Nearby object 1: checked region begins 1B after and ends 1B after
mudflap object 0x95935d0: name=`malloc region'
bounds=[0x9593588,0x9593588] size=1 area=heap check=0r/0w liveness=0
alloc time=1155044090.467892 pc=0xb7e42ccd
      /usr/lib/libmudflap.so.0(__mf_register+0x3d) [0xb7e42ccd]
      /usr/lib/libmudflap.so.0(__real_malloc+0xde) [0xb7e441ae]
      ./a.out(main+0x30) [0x80486b4]
      /usr/lib/libmudflap.so.0(__wrap_main+0x49) [0xb7e42d29]
number of nearby objects: 1
*******
mudflap violation 2 (check/write): time=1155044090.468306 ptr=0x9593587 size=1
pc=0xb7e4326d location=`mudflap_crash.c:7 (main)'
      /usr/lib/libmudflap.so.0(__mf_check+0x3d) [0xb7e4326d]
      ./a.out(main+0x115) [0x8048799]
      /usr/lib/libmudflap.so.0(__wrap_main+0x49) [0xb7e42d29]
Nearby object 1: checked region begins 1B before and ends 1B before
mudflap object 0x95935d0: name=`malloc region'
number of nearby objects: 1

However, building the same program with the multithreaded version of mudflap,
i.e. "gcc -fmudflapth <program name> -pthread -lmudflapth" produces no
violatings or warnings -- no problem is reported by mudflap.


-- 
           Summary: Array underruns and overruns not detected by the
                    multithreaded mudflap
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libmudflap
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: vesselinpeev at hotmail dot com
  GCC host triplet: 386


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28654

Reply via email to