This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: mudflap: how do I give size for 'void *' objects? - example


Eyal Lebedinsky wrote:
> 
> I have a problem where I get a large number of reported violations
> when accessing objects acquired through something like
>         p = shmat()
> where the size of the object is unknown (unless mudflap uses
> extra internal knowledge).

Here is a simple program that demonstrates the problem with ctime().
Note how the fprintf() works OK (no violation) but the strlen()
fails. I assume that mudflap has its own strlen() wrapper that
trips on the "foreign" pointer returned from ctime().

  -----------------------------------------------------
#!/bin/sh

mf="/usr/local/gcc-mudflap"

cat >zz.c <<EOF
#include <stdio.h>
#include <time.h>
#include <string.h>

int main ()
{
        time_t  t;
        char    *p;
        int     l;

        t = time (NULL);
        p = ctime (&t);

        fprintf (stderr, "%s", p);

        l = (int)strlen (p);

        return (0);
}
EOF

export LD_LIBRARY_PATH="$mf/lib"

 cc="$mf/bin/i686-pc-linux-gnu-gcc-3.5-tree-ssa -fmudflap -g -O0"
#cc="gcc"

test -f zz && rm zz
$cc -Wall -o zz zz.c
./zz
  -----------------------------------------------------

--
Eyal Lebedinsky (eyal at eyal dot emu dot id dot au) <http://samba.org/eyal/>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]