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]

tree-ssa -fmudflap problems


I am trying to use the tree-ssa branch with -fmudflap.

I am on Linux 2.4.20/21, Debian 3.0r1, i386.

I fetched the branch (off cvs) and built as recommended:
	dir="gcc-mudflap"
	mkdir $dir
	cd $dir
	../gcc/configure --prefix=/usr/local/$dir
	make bootstrap
	make install
and then tried a test program (attached below). I see problems
with dlclose(), which at times lead to a segmentation fault.

My original problem comes from a complex system where the problem
leads to an deep loop. The stack looks like shown below.

I should say that the program under test uses pthreads, but at the
point of the crash it [my main()] was not yet enterted.

  --------------------------- test run -----------------
(gdb) run
Starting program: /data2/ssa/builds/mudflapn/bin/showtime 
[New Thread 1024 (LWP 20009)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 20009)]
0x402936cf in resolve_single_dynamic (target=0x402ac40c, 
    name=0x4029aaa2 "calloc") at
../../../gcc/libmudflap/mf-runtime.c:401
401     {
(gdb) where 20
#0  0x402936cf in resolve_single_dynamic (target=0x402ac40c, 
    name=0x4029aaa2 "calloc") at
../../../gcc/libmudflap/mf-runtime.c:401
#1  0x402937bb in __mf_resolve_dynamics ()
    at ../../../gcc/libmudflap/mf-runtime.c:425
#2  0x40297375 in calloc (c=1, n=16) at
../../../gcc/libmudflap/mf-hooks.c:120
#3  0x402ae269 in dlerror () from /lib/libdl.so.2
#4  0x402adfe3 in dlsym () from /lib/libdl.so.2
#5  0x402936fa in resolve_single_dynamic (target=0x402ac40c, 
    name=0x4029aaa2 "calloc") at
../../../gcc/libmudflap/mf-runtime.c:405
#6  0x402937bb in __mf_resolve_dynamics ()
    at ../../../gcc/libmudflap/mf-runtime.c:425
#7  0x40297375 in calloc (c=1, n=16) at
../../../gcc/libmudflap/mf-hooks.c:120
#8  0x402ae269 in dlerror () from /lib/libdl.so.2
#9  0x402adfe3 in dlsym () from /lib/libdl.so.2
#10 0x402936fa in resolve_single_dynamic (target=0x402ac40c, 
    name=0x4029aaa2 "calloc") at
../../../gcc/libmudflap/mf-runtime.c:405
#11 0x402937bb in __mf_resolve_dynamics ()
    at ../../../gcc/libmudflap/mf-runtime.c:425
#12 0x40297375 in calloc (c=1, n=16) at
../../../gcc/libmudflap/mf-hooks.c:120
#13 0x402ae269 in dlerror () from /lib/libdl.so.2
#14 0x402adfe3 in dlsym () from /lib/libdl.so.2
#15 0x402936fa in resolve_single_dynamic (target=0x402ac40c, 
    name=0x4029aaa2 "calloc") at
../../../gcc/libmudflap/mf-runtime.c:405
#16 0x402937bb in __mf_resolve_dynamics ()
    at ../../../gcc/libmudflap/mf-runtime.c:425
#17 0x40297375 in calloc (c=1, n=16) at
../../../gcc/libmudflap/mf-hooks.c:120
#18 0x402ae269 in dlerror () from /lib/libdl.so.2
#19 0x402adfe3 in dlsym () from /lib/libdl.so.2
(More stack frames follow...)
(gdb) where -20
#43532 0x40297375 in calloc (c=1, n=16)
    at ../../../gcc/libmudflap/mf-hooks.c:120
#43533 0x402ae269 in dlerror () from /lib/libdl.so.2
#43534 0x402adfe3 in dlsym () from /lib/libdl.so.2
#43535 0x402936fa in resolve_single_dynamic (target=0x402ac40c, 
    name=0x4029aaa2 "calloc") at
../../../gcc/libmudflap/mf-runtime.c:405
#43536 0x402937bb in __mf_resolve_dynamics ()
    at ../../../gcc/libmudflap/mf-runtime.c:425
#43537 0x40297375 in calloc (c=1, n=16)
    at ../../../gcc/libmudflap/mf-hooks.c:120
#43538 0x402ae269 in dlerror () from /lib/libdl.so.2
#43539 0x402adfe3 in dlsym () from /lib/libdl.so.2
#43540 0x402936fa in resolve_single_dynamic (target=0x402ac40c, 
    name=0x4029aaa2 "calloc") at
../../../gcc/libmudflap/mf-runtime.c:405
#43541 0x402937bb in __mf_resolve_dynamics ()
    at ../../../gcc/libmudflap/mf-runtime.c:425
#43542 0x40297375 in calloc (c=1, n=16)
    at ../../../gcc/libmudflap/mf-hooks.c:120
#43543 0x402ae269 in dlerror () from /lib/libdl.so.2
#43544 0x402adfe3 in dlsym () from /lib/libdl.so.2
#43545 0x402936fa in resolve_single_dynamic (target=0x402ac40c, 
    name=0x4029aaa2 "calloc") at
../../../gcc/libmudflap/mf-runtime.c:405
#43546 0x402937bb in __mf_resolve_dynamics ()
    at ../../../gcc/libmudflap/mf-runtime.c:425
#43547 0x40293864 in __mf_init () at
../../../gcc/libmudflap/mf-runtime.c:517
#43548 0x4029a7aa in __do_global_ctors_aux ()
   from /usr/local/gcc-mudflap/lib/libmudflap.so.0
#43549 0x40292c66 in _init () from
/usr/local/gcc-mudflap/lib/libmudflap.so.0
#43550 0x40009cc7 in call_init () from /lib/ld-linux.so.2
#43551 0x40009e1d in _dl_init () from /lib/ld-linux.so.2
(gdb) q
A debugging session is active.
Do you still want to close the debugger?(y or n) y

  --------------------------- test script -----------------
#!/bin/sh

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

cat >zz.c <<EOF

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <dlfcn.h>

static void test_dl (char *lib, char *sym)
{
        void            *p;
        char            *e;

        printf ("test: dl ('%s', '%s')\n", lib, sym);

        p = NULL;
        printf ("dlopen(%s)=%p\n",
                lib,
                p = dlopen (lib, RTLD_NOW|RTLD_LOCAL));
        printf ("dlerror='%s'\n",
                NULL == (e = dlerror ()) ? "none" : e);
        if (NULL == p)
                return;

        printf ("dlsym(%s)=%p\n",
                sym,
                dlsym (p, sym));
        printf ("dlerror='%s'\n",
                NULL == (e = dlerror ()) ? "none" : e);

        printf ("dlclose=%d\n",
                dlclose (p));
        p = NULL;
        printf ("dlerror='%s'\n",
                NULL == (e = dlerror ()) ? "none" : e);
}

int main (int argc, char *argv[])
{
        printf ("test: starting\n");

        test_dl ("/usr/lib/libm.so", "cos");
        test_dl ("/usr/lib/libvga.so", "vga_init");

        printf ("test: finished\n");

        return (0);
}
EOF

export LD_LIBRARY_PATH="$mf/lib"
$mf/bin/i686-pc-linux-gnu-gcc-3.5-tree-ssa -Wall -fmudflap -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]