public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/46822] New: printf( "%f" ) segv when called from pthread_once
@ 2010-12-06 15:07 isdmter at gmail dot com
  2010-12-06 15:14 ` [Bug c/46822] " isdmter at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: isdmter at gmail dot com @ 2010-12-06 15:07 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: printf( "%f" ) segv when called from pthread_once
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: isdmter@gmail.com


Created attachment 22658
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22658
A 20 line source code that triggers the bug

Hi,

I noticed that a simple call to printf for a double argument always crashes my
program exclusively when called inside a pthread_once function. The call
succeeds in other cases.

The crash occurs for many different versions of GCC (3.3.6, 3.4.6, 4.1.2,
4.3.1, 4.3.2, 4.4.2 and 4.5.1) and also for various printf-like functions
(sprintf, snprintf, etc.).

Thanks.
Isdmter

Configuration:

GCC 4.5.1:
Using built-in specs.
COLLECT_GCC=/local00/home/isdmter/products/gcc-4.5.1/bin/gcc
COLLECT_LTO_WRAPPER=/local00/home/isdmter/products/gcc-4.5.1/libexec/gcc/x86_64-linux-gnu/4.5.1/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ./configure -v --enable-languages=c,c++,fortran --enable-gold
--enable-shared --without-included-gettext --enable-threads=posix --enable-nls
--enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug
--enable-mpfr --enable-gmp --enable-checking=release x86_64-linux-gnu
--with-gmp-include=/local00/home/isdmter/products/gmp-5.0.1/include
--with-gmp-lib=/local00/home/isdmter/products/gmp-5.0.1/lib
--with-mpfr-include=/local00/home/isdmter/products/mpfr-3.0.0/include
--with-mpfr-lib=/local00/home/isdmter/products/mpfr-3.0.0/lib
--with-mpc-include=/local00/home/isdmter/products/mpc-0.8.2/include
--with-mpc-lib=/local00/home/isdmter/products/mpc-0.8.2/lib
--prefix=/local00/home/isdmter/products/gcc-4.5.1 --disable-multilib
--disable-bootstrap --with-system-zlib LDFLAGS='-Wl,-rpath
-Wl,/local00/home/isdmter/products/gmp-5.0.1/lib -Wl,-rpath
-Wl,/local00/home/isdmter/products/mpfr-3.0.0/lib -Wl,-rpath
-Wl,/local00/home/isdmter/products/mpc-0.8.2/lib'
Thread model: posix
gcc version 4.5.1 (GCC)

System:
Debian etch
Linux 2.6.18-4-amd64 #1 SMP Fri May 4 00:37:33 UTC 2007 x86_64 GNU/Linux

Commands to reproduce the bug:
$ gcc -Wall -save-temps -o main -pthread -lpthread main.c
$ ./main


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c/46822] printf( "%f" ) segv when called from pthread_once
  2010-12-06 15:07 [Bug c/46822] New: printf( "%f" ) segv when called from pthread_once isdmter at gmail dot com
@ 2010-12-06 15:14 ` isdmter at gmail dot com
  2011-01-17 23:48 ` nicola at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: isdmter at gmail dot com @ 2010-12-06 15:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from isdmter at gmail dot com 2010-12-06 15:14:45 UTC ---
Oops, I forgot to show my output:
$ ./main
0
0.000000
0
Segmentation fault

The first two lines are the first call to f() (directly from the main()),
whereas the last two correspond to the second of f() (from pthread_once()).

Isdmter


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c/46822] printf( "%f" ) segv when called from pthread_once
  2010-12-06 15:07 [Bug c/46822] New: printf( "%f" ) segv when called from pthread_once isdmter at gmail dot com
  2010-12-06 15:14 ` [Bug c/46822] " isdmter at gmail dot com
@ 2011-01-17 23:48 ` nicola at gcc dot gnu.org
  2011-01-17 23:52 ` [Bug middle-end/46822] " pinskia at gcc dot gnu.org
  2013-11-10  8:19 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: nicola at gcc dot gnu.org @ 2011-01-17 23:48 UTC (permalink / raw)
  To: gcc-bugs

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

Nicola Pero <nicola at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2011.01.17 22:49:07
                 CC|                            |nicola at gcc dot gnu.org
     Ever Confirmed|0                           |1

--- Comment #2 from Nicola Pero <nicola at gcc dot gnu.org> 2011-01-17 22:49:07 UTC ---
Isdmter

thanks for your report and the testcase.  The attached testcase works for me
using GCC 4.6.0 (pre-release) --

 gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/gcc/trunk7/libexec/gcc/i686-pc-linux-gnu/4.6.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../trunk7/configure --prefix=/opt/gcc/trunk7
--enable-languages=c,objc,c++,obj-c++ --enable-objc-gc
--with-gmp=/opt/gcc/auxiliary/ --with-mpfr=/opt/gcc/auxiliary/
--with-mpc=/opt/gcc/auxiliary/ --enable-checking=release : (reconfigured)
../trunk7/configure --prefix=/opt/gcc/trunk7 --enable-objc-gc
--with-gmp=/opt/gcc/auxiliary/ --with-mpfr=/opt/gcc/auxiliary/
--with-mpc=/opt/gcc/auxiliary/ --enable-checking=release
--enable-languages=c,c++,lto,objc,obj-c++ --no-create --no-recursion
Thread model: posix
gcc version 4.6.0 20110116 (experimental) (GCC) 

[nicola@lampone ~]$ gcc -Wall -save-temps -o main -pthread -lpthread main.c
[nicola@lampone ~]$ ./main 
0
0.000000
0
0.000000
[nicola@lampone ~]$

I also tried on a x86_64-unknown-linux-gnu AMD machine, similar to yours, and
it works fine there too.

Maybe you could manage to try with GCC 4.6.0 (prerelease) and confirm that
you're still seeing the bug there ?

Thanks


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug middle-end/46822] printf( "%f" ) segv when called from pthread_once
  2010-12-06 15:07 [Bug c/46822] New: printf( "%f" ) segv when called from pthread_once isdmter at gmail dot com
  2010-12-06 15:14 ` [Bug c/46822] " isdmter at gmail dot com
  2011-01-17 23:48 ` nicola at gcc dot gnu.org
@ 2011-01-17 23:52 ` pinskia at gcc dot gnu.org
  2013-11-10  8:19 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-01-17 23:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-01-17 22:53:24 UTC ---
I wonder if this was a bug in glibc.  I have:
apinski@apinskidesktop:~$ /lib/libc.so.6 
GNU C Library stable release version 2.7, by Roland McGrath et al.
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.3.2.
Compiled on a Linux >>2.6.32-5-amd64<< system on 2010-10-21.
Available extensions:
    crypt add-on version 2.1 by Michael Glad and others
    GNU Libidn by Simon Josefsson
    Native POSIX Threads Library by Ulrich Drepper et al
    BIND-8.2.3-T5B
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.

And it works for me.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug middle-end/46822] printf( "%f" ) segv when called from pthread_once
  2010-12-06 15:07 [Bug c/46822] New: printf( "%f" ) segv when called from pthread_once isdmter at gmail dot com
                   ` (2 preceding siblings ...)
  2011-01-17 23:52 ` [Bug middle-end/46822] " pinskia at gcc dot gnu.org
@ 2013-11-10  8:19 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-11-10  8:19 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|---                         |INVALID

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
No feedback in over 2 years so closing.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-11-10  8:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-06 15:07 [Bug c/46822] New: printf( "%f" ) segv when called from pthread_once isdmter at gmail dot com
2010-12-06 15:14 ` [Bug c/46822] " isdmter at gmail dot com
2011-01-17 23:48 ` nicola at gcc dot gnu.org
2011-01-17 23:52 ` [Bug middle-end/46822] " pinskia at gcc dot gnu.org
2013-11-10  8:19 ` pinskia at gcc dot gnu.org

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).