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]

Weird printf() bug


I've got a really odd problem I'm seeing with egcs 970917 and 970922 (+
reg-stack.c, loop.c and rtlanal.c patches).  I compile a library I'm
writing, and link it with a piece of code that simply calls printf().  This
code *never* calls anything in my library; it contains only a function
(which is never called) and a variable declaration in the function of a type
that my library provides.  Basically, enough to force linking something from
my library.

I get this interesting error as soon as I hit the first printf() (and this
can be fprintf(stdout, ...), too, but *not* sprintf(...), sprintf() works
fine):

GDB is free software and you are welcome to 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.
GDB 4.16 (i586-unknown-linux), Copyright 1996 Free Software Foundation,
Inc...
Core was generated by ./sanity'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libm.so.5...done.
Reading symbols from /lib/libc.so.5...done.
Reading symbols from /lib/ld-linux.so.1...done.
#0  0x4005fbdf in _IO_vfprintf (s=0x805a2b4, format=0x8058ab8 "", 
    ap=0xbffff838)
(gdb) bt
#0  0x4005fbdf in _IO_vfprintf (s=0x805a2b4, format=0x8058ab8 "", 
    ap=0xbffff838)
#1  0x4005efe3 in _IO_printf (format=0x1 "")
#2  0x8049c9e in _start ()
Current language:  auto; currently c
(gdb) 

If I don't link with the library, the problem disappears.  I find it
interesting that the problem doesn't manifest itself with sprintf().

Does anyone have any tips on tracking this problem down?

BTW, I've also got problems with the default exception handling mechanism
for Linux x86 in 970922 that goes away with -fsjlj-exceptions.  No concise
sample code, though.  I'll see what I can come up with.

-- 
Steve Madsen  <steve@moonglade.com>              PGP key available


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