This is the mail archive of the gcc-bugs@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]

[Bug c/31514] New: simple prog causes segfault in ptmalloc_init


this small program causes a seg fault in libc.
i don't think this is a libc bug because insignificant changes to the program
cure the problem.

i have run valgrind with the executable, too

in the program below, change the assignment  c=s[1]  to   c=0
and the seg fault disappears

to run the program, it needs one argument, say,  aa

main(c,v)char**v;
{int i=1,*z,_a[30];
 while(i<c)
 {char*s=v[i++],c=s[1];
  _a[c]=1;z=malloc(2);
 }
}


[jack@fedora i]$ gcc -v  b.c
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/u
sr/share/info --enable-shared --enable-threads=posix --enable-checking=release
-
-with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-
libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada
--enable
-java-awt=gtk --disable-dssi
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.
0/jre --with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.0 20060304 (Red Hat 4.1.0-3)
 /usr/libexec/gcc/i386-redhat-linux/4.1.0/cc1 -quiet -v b.c -quiet -dumpbase
b.c
 -mtune=generic -auxbase b -version -o /tmp/ccQl7Khk.s
ignoring nonexistent directory
"/usr/lib/gcc/i386-redhat-linux/4.1.0/../../../..
/i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/gcc/i386-redhat-linux/4.1.0/include
 /usr/include
End of search list.
GNU C version 4.1.0 20060304 (Red Hat 4.1.0-3) (i386-redhat-linux)
        compiled by GNU C version 4.1.0 20060304 (Red Hat 4.1.0-3).
GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=32018
Compiler executable checksum: bba44d5df49c85f0bc824786061245c8
b.c: In function â?~mainâ?T:
b.c:5: warning: incompatible implicit declaration of built-in function
â?~malloc
â?T
 as -V -Qy -o /tmp/ccLvgGzq.o /tmp/ccQl7Khk.s
GNU assembler version 2.16.91.0.6 (i386-redhat-linux) using BFD version
2.16.91.
0.6 20060212
 /usr/libexec/gcc/i386-redhat-linux/4.1.0/collect2 --eh-frame-hdr -m elf_i386
-d
ynamic-linker /lib/ld-linux.so.2
/usr/lib/gcc/i386-redhat-linux/4.1.0/../../../c
rt1.o /usr/lib/gcc/i386-redhat-linux/4.1.0/../../../crti.o
/usr/lib/gcc/i386-red
hat-linux/4.1.0/crtbegin.o -L/usr/lib/gcc/i386-redhat-linux/4.1.0
-L/usr/lib/gcc
/i386-redhat-linux/4.1.0 -L/usr/lib/gcc/i386-redhat-linux/4.1.0/../../..
/tmp/cc
LvgGzq.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s
--no-as-needed /usr/lib/gcc/i386-redhat-linux/4.1.0/crtend.o
/usr/lib/gcc/i386-r
edhat-linux/4.1.0/../../../crtn.o


[jack@fedora i]$ ./a.out aa
Segmentation fault (core dumped)

[jack@fedora i]$ gdb ./a.out core.23091
GNU gdb Red Hat Linux (6.3.0.0-1.122rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...
(no debugging symbols found)
Using host libthread_db library "/lib/libthread_db.so.1".

Reading symbols from shared object read from target memory...(no debugging
symbo
ls found)...done.
Loaded system supplied DSO at 0x573000
Core was generated by `./a.out -c 1'.
Program terminated with signal 11, Segmentation fault.

warning: svr4_current_sos: Can't read pathname for load map: Input/output error

Reading symbols from /lib/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib/ld-linux.so.2

#0  0x0070d787 in ptmalloc_init () from /lib/libc.so.6
(gdb) where
#0  0x0070d787 in ptmalloc_init () from /lib/libc.so.6
#1  0x007111a8 in malloc_hook_ini () from /lib/libc.so.6
#2  0x00710c37 in malloc () from /lib/libc.so.6
#3  0x080483e6 in main ()
(gdb)


-- 
           Summary: simple prog causes segfault in ptmalloc_init
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: effbiae at gmail dot com
  GCC host triplet: fedora core 5


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


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