This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/51846] New: Compiled programs suffer from infinite recursion when using -finstrument-functions with optimizations
- From: "daniel at totalueberwachung dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 13 Jan 2012 12:05:03 +0000
- Subject: [Bug c/51846] New: Compiled programs suffer from infinite recursion when using -finstrument-functions with optimizations
- Auto-submitted: auto-generated
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.