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

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