public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/51846] New: Compiled programs suffer from infinite recursion when using -finstrument-functions with optimizations
@ 2012-01-13 12:06 daniel at totalueberwachung dot de
  2012-01-13 12:42 ` [Bug c/51846] " daniel at totalueberwachung dot de
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: daniel at totalueberwachung dot de @ 2012-01-13 12:06 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51846
           Summary: Compiled programs suffer from infinite recursion when
                    using -finstrument-functions with optimizations
    Classification: Unclassified
           Product: gcc
           Version: 4.5.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: daniel@totalueberwachung.de


Created attachment 26313
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26313
Testcase

While trying to debug a different issue I've been having with instrumentation
I've run into this problem. It seems that with any sort of optimization enabled
the compiler doesn't obey the no_instrument_function attribute. Attached is a
small testcase. The output I get when compiling with and without optimization
or instrumentation is this:

$ gcc -O0 -o main main.c 
$ ./main 
Start
End
$ gcc -Os -o main main.c 
$ ./main 
Start
End
$ gcc -Os -finstrument-functions -o main main.c 
$ ./main 
Segmentation fault
$ gcc -O0 -finstrument-functions -o main main.c 
$ ./main 
-> 0x400674 0x7fcbd75eb09d
Start
-> 0x400652 0x4006a1
<- 0x400652 0x4006a1
End
<- 0x400674 0x7fcbd75eb09d

Attached to a debugger or when looking at the assembly you can easily see that
the __cyg_profile_func_enter function has a call to itself when compiled with
any optimization setting other than O0.


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

* [Bug c/51846] Compiled programs suffer from infinite recursion when using -finstrument-functions with optimizations
  2012-01-13 12:06 [Bug c/51846] New: Compiled programs suffer from infinite recursion when using -finstrument-functions with optimizations daniel at totalueberwachung dot de
@ 2012-01-13 12:42 ` daniel at totalueberwachung dot de
  2012-01-16 10:14 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: daniel at totalueberwachung dot de @ 2012-01-13 12:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Daniel Willmann <daniel at totalueberwachung dot de> 2012-01-13 12:20:25 UTC ---
Here's my gcc version, I noticed that Debian's GCC (tested gcc-4.53-10 as well
as gcc-4.6.2-11) works as expected.

alphaone@adrastea ~ $ gcc --version -v
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.3/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.5.3/lto-wrapper
gcc (Gentoo 4.5.3-r2 p1.0, pie-0.4.6) 4.5.3
Copyright (C) 2010 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.


Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-4.5.3-r2/work/gcc-4.5.3/configure --prefix=/usr
--bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.3
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.3
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.3/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.5.3/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/include/g++-v4
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec
--disable-fixed-point --without-ppl --without-cloog --enable-lto --enable-nls
--without-included-gettext --with-system-zlib --disable-werror
--enable-secureplt --enable-multilib --enable-libmudflap --disable-libssp
--enable-libgomp
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.5.3/python
--enable-checking=release --enable-java-awt=gtk
--enable-languages=c,c++,java,fortran --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all
--with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.5.3-r2 p1.0,
pie-0.4.6'
Thread model: posix
gcc version 4.5.3 (Gentoo 4.5.3-r2 p1.0, pie-0.4.6) 
COLLECT_GCC_OPTIONS='-fversion' '-v' '-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-pc-linux-gnu/4.5.3/cc1 -quiet -v help-dummy
-D_FORTIFY_SOURCE=2 -quiet -dumpbase help-dummy -mtune=generic -march=x86-64
-auxbase help-dummy -version -fversion -o /tmp/ccZQmZs8.s
GNU C (Gentoo 4.5.3-r2 p1.0, pie-0.4.6) version 4.5.3 (x86_64-pc-linux-gnu)
    compiled by GNU C version 4.5.3, GMP version 5.0.2, MPFR version 3.0.1-p4,
MPC version 0.8.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='-fversion' '-v' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/as
-V -Qy --64 --version -o /tmp/ccxiIKa1.o /tmp/ccZQmZs8.s
GNU assembler version 2.21.1 (x86_64-pc-linux-gnu) using BFD version (GNU
Binutils) 2.21.1
GNU assembler (GNU Binutils) 2.21.1
Copyright 2011 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `x86_64-pc-linux-gnu'.
COMPILER_PATH=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.5.3/:/usr/libexec/gcc/x86_64-pc-linux-gnu/4.5.3/:/usr/libexec/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/:/usr/lib/gcc/x86_64-pc-linux-gnu/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/
LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/lib/:/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-fversion' '-v' '-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-pc-linux-gnu/4.5.3/collect2 --eh-frame-hdr -m
elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 --version
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../lib64/crt1.o
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../lib64/crti.o
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/crtbegin.o
-L/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3
-L/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../lib64 -L/lib/../lib64
-L/usr/lib/../lib64
-L/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/lib
-L/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../.. /tmp/ccxiIKa1.o -lgcc
--as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/crtend.o
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../lib64/crtn.o
GNU ld (GNU Binutils) 2.21.1
Copyright 2011 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.


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

* [Bug c/51846] Compiled programs suffer from infinite recursion when using -finstrument-functions with optimizations
  2012-01-13 12:06 [Bug c/51846] New: Compiled programs suffer from infinite recursion when using -finstrument-functions with optimizations daniel at totalueberwachung dot de
  2012-01-13 12:42 ` [Bug c/51846] " daniel at totalueberwachung dot de
@ 2012-01-16 10:14 ` rguenth at gcc dot gnu.org
  2021-09-17  8:56 ` [Bug middle-end/51846] " pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-01-16 10:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-01-16 10:07:52 UTC ---
Works for me with stock FSF GCC 4.5.3 and with SuSEs GCC 4.5.3.


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

* [Bug middle-end/51846] Compiled programs suffer from infinite recursion when using -finstrument-functions with optimizations
  2012-01-13 12:06 [Bug c/51846] New: Compiled programs suffer from infinite recursion when using -finstrument-functions with optimizations daniel at totalueberwachung dot de
  2012-01-13 12:42 ` [Bug c/51846] " daniel at totalueberwachung dot de
  2012-01-16 10:14 ` rguenth at gcc dot gnu.org
@ 2021-09-17  8:56 ` pinskia at gcc dot gnu.org
  2021-09-17  8:57 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-17  8:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51846

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |WORKSFORME
          Component|c                           |middle-end
           Keywords|                            |wrong-code

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I looked and upstream GCC 4.5.3 produces the correct code.

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

* [Bug middle-end/51846] Compiled programs suffer from infinite recursion when using -finstrument-functions with optimizations
  2012-01-13 12:06 [Bug c/51846] New: Compiled programs suffer from infinite recursion when using -finstrument-functions with optimizations daniel at totalueberwachung dot de
                   ` (2 preceding siblings ...)
  2021-09-17  8:56 ` [Bug middle-end/51846] " pinskia at gcc dot gnu.org
@ 2021-09-17  8:57 ` pinskia at gcc dot gnu.org
  2021-09-17  8:59 ` pinskia at gcc dot gnu.org
  2021-09-17  9:04 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-17  8:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51846

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|WORKSFORME                  |---
             Status|RESOLVED                    |UNCONFIRMED

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Actually I just noticed -D_FORTIFY_SOURCE=2 was being used ....

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

* [Bug middle-end/51846] Compiled programs suffer from infinite recursion when using -finstrument-functions with optimizations
  2012-01-13 12:06 [Bug c/51846] New: Compiled programs suffer from infinite recursion when using -finstrument-functions with optimizations daniel at totalueberwachung dot de
                   ` (3 preceding siblings ...)
  2021-09-17  8:57 ` pinskia at gcc dot gnu.org
@ 2021-09-17  8:59 ` pinskia at gcc dot gnu.org
  2021-09-17  9:04 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-17  8:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51846

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |6.2.0
      Known to work|                            |6.3.0, 6.4.0, 7.1.0

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Looks like it was fixed in GCC 6.3.0 and GCC 7+.  Looking for the change which
might have fixed this one.

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

* [Bug middle-end/51846] Compiled programs suffer from infinite recursion when using -finstrument-functions with optimizations
  2012-01-13 12:06 [Bug c/51846] New: Compiled programs suffer from infinite recursion when using -finstrument-functions with optimizations daniel at totalueberwachung dot de
                   ` (4 preceding siblings ...)
  2021-09-17  8:59 ` pinskia at gcc dot gnu.org
@ 2021-09-17  9:04 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-17  9:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51846

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 78333 in the end.

*** This bug has been marked as a duplicate of bug 78333 ***

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

end of thread, other threads:[~2021-09-17  9:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-13 12:06 [Bug c/51846] New: Compiled programs suffer from infinite recursion when using -finstrument-functions with optimizations daniel at totalueberwachung dot de
2012-01-13 12:42 ` [Bug c/51846] " daniel at totalueberwachung dot de
2012-01-16 10:14 ` rguenth at gcc dot gnu.org
2021-09-17  8:56 ` [Bug middle-end/51846] " pinskia at gcc dot gnu.org
2021-09-17  8:57 ` pinskia at gcc dot gnu.org
2021-09-17  8:59 ` pinskia at gcc dot gnu.org
2021-09-17  9:04 ` 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).