public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Eyal Lebedinsky <eyal@eyal.emu.id.au>
To: "list, gcc" <gcc@gcc.gnu.org>, "Eigler, Frank Ch." <fche@redhat.com>
Subject: mudflap - Another simple failure
Date: Sat, 05 Apr 2003 12:16:00 -0000	[thread overview]
Message-ID: <3E8E935C.1286C0A2@eyal.emu.id.au> (raw)

I am getting better at this...

Well, I actually managed to build a very last system with this and
it mostly works, except I get a huge exception report which slows
everything to a crawl. I think I am almost there (with
multithreading disabled though).

As always, the example below is what I ended up after reducing
a much larger program. I tried a few simpler forms but they did
not fail.

And while I am on the ebox, why do I not see a proper stack trace
with line numbers? What I got for this test is below. The
	'zz.c:19 (usemem)'
is correct, but I would have liked to see (and expected)
	'zz.c:48 (main)'
for the next stack frame, etc.. I only see
	./zz(main+0x52) [0x8048876]
I built with '-g -O0' specifically to expedite more accurate
reporting.

Nevertheless, it is so close that I can smell it, and if we can
reduce the 6GB report to a more manageable size then I expect
to see my secret programming sins clearly exposed.

  ----------------------------------------------------
buf=0x8051f30
p=0x8051f30 i=0
*******
mudflap violation 1 (check/read): time=1049530365.371258 ptr=08051f30
size=1 pc=080487f9 location=`zz.c:19 (usemem)'
      ./zz(__mf_check+0x245) [0x80487f9]
      ./zz(main+0x52) [0x8048876]
      /lib/libc.so.6(__libc_start_main+0xbb) [0x4005714f]
Nearby object 1: checked region begins 0B into and ends 0B into
mudflap object 08051f60: name=`malloc region'
bounds=[08051f30,08051f34] size=5 area=heap check=1r/0w liveness=1
watching=0
alloc time=1049530365.371099 pc=40019f32
      /usr/local/gcc-mudflap/lib/libmudflap.so.0(__real_malloc+0x142)
[0x40019f32]
      ./zz(__mf_check+0xfc) [0x80486b0]
      ./zz(main+0x25) [0x8048849]
number of nearby objects: 1
p=0x8051f30 i=1
*******
mudflap violation 2 (check/read): time=1049530365.371459 ptr=08051f31
size=1 pc=080487f9 location=`zz.c:19 (usemem)'
      ./zz(__mf_check+0x245) [0x80487f9]
      ./zz(main+0x52) [0x8048876]
      /lib/libc.so.6(__libc_start_main+0xbb) [0x4005714f]
Nearby object 1: checked region begins 1B into and ends 1B into
mudflap object 08051f60: name=`malloc region'
number of nearby objects: 1
p=0x8051f30 i=2
*******
mudflap violation 3 (check/read): time=1049530365.371583 ptr=08051f32
size=1 pc=080487f9 location=`zz.c:19 (usemem)'
      ./zz(__mf_check+0x245) [0x80487f9]
      ./zz(main+0x52) [0x8048876]
      /lib/libc.so.6(__libc_start_main+0xbb) [0x4005714f]
Nearby object 1: checked region begins 2B into and ends 2B into
mudflap object 08051f60: name=`malloc region'
number of nearby objects: 1
p=0x8051f30 i=3
*******
mudflap violation 4 (check/read): time=1049530365.371704 ptr=08051f33
size=1 pc=080487f9 location=`zz.c:19 (usemem)'
      ./zz(__mf_check+0x245) [0x80487f9]
      ./zz(main+0x52) [0x8048876]
      /lib/libc.so.6(__libc_start_main+0xbb) [0x4005714f]
Nearby object 1: checked region begins 3B into and ends 3B into
mudflap object 08051f60: name=`malloc region'
number of nearby objects: 1
p=0x8051f30 i=4
*******
mudflap violation 5 (check/read): time=1049530365.371825 ptr=08051f34
size=1 pc=080487f9 location=`zz.c:19 (usemem)'
      ./zz(__mf_check+0x245) [0x80487f9]
      ./zz(main+0x52) [0x8048876]
      /lib/libc.so.6(__libc_start_main+0xbb) [0x4005714f]
Nearby object 1: checked region begins 4B into and ends 4B into
mudflap object 08051f60: name=`malloc region'
number of nearby objects: 1
  -----------------------------------------------
#!/bin/sh

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

cat >zz.c <<EOF
#include <stdio.h>
#include <stdlib.h>

static char     *buf = NULL;

static void getmem (char **p, int n)
{
        *p = malloc (n);
}

static void usemem (int n)
{
        char    *p;
        int     i;

        p = buf;
        for (i = 0; i < n; ++i) {
                fprintf (stderr, "p=%p i=%d\n", p, i);
                if (' ' == p[i])
                        break;
        }
}

int main ()
{
        getmem (&buf, 5);
        fprintf (stderr, "buf=%p\n", buf);

        usemem (5);

        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@eyal.emu.id.au) <http://samba.org/eyal/>

                 reply	other threads:[~2003-04-05  8:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3E8E935C.1286C0A2@eyal.emu.id.au \
    --to=eyal@eyal.emu.id.au \
    --cc=fche@redhat.com \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).