[Bug middle-end/52544] compilation fails with -finstrument-functions and sse c code
rodrigo at sdfg dot com.ar
gcc-bugzilla@gcc.gnu.org
Fri Jun 28 15:25:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52544
--- Comment #5 from Rodrigo Campos <rodrigo at sdfg dot com.ar> ---
Ohh, forgot to say, but if I just don't compile with "-finstrument-functions"
the code works as expected. With gcc 4.7, 4.5 and 4.4.
Although, when I compile with gcc 4.5 and 4.4, everything compiles and links.
But if my instrument function does a printf, I get a memory corruption:
void __cyg_profile_func_enter(void *func, void *caller)
{
printf("just printing something\n");
return;
}
void __cyg_profile_func_exit(void *func, void *caller)
{
return;
}
If I just remove the call to printf and leave a "return;" it seems to work
(althoug not sure if optimized out, didn't check the assembly). Also, if I just
add an integer, it seems to work okay. I tried creating a big array on the
stack and see if I saw memory corruption, but I didnt. I tried this:
int dummy;
void __cyg_profile_func_enter(void *func, void *caller)
{
//printf("just printing something\n");
dummy++;
int a = 0;
a++;
int array[1000];
for (int i = 0; i < 1000; i++)
array[i] = 3;
return;
}
void __cyg_profile_func_exit(void *func, void *caller)
{
//printf("just printing something\n");
dummy--;
int a = 0;
a++;
int array[1000];
for (int i = 0; i < 1000; i++)
array[i] = 3;
return;
}
So, for some reason, it doesn't like a printf there (there are various threads
in the program, I tried just in case serializing printf calls with a mutex but
it didn't help). Also, if I use a macro in my library that uses snprintf in the
end to print something, it corrupts the memory too.
Ohh, also, it doesn't matter if the call to printf is in the "_enter" or
"_exit" function, it always seems to corrupt the memory.
So, to sum up, it seems that with recent versions of gcc (as reported in the
original bug report) it doesn't compile the sse code in the original bugreport
and it doesn't compile some other type of functions. These kind of functions
seems to be used in P99 (link to the project in my previous post) and some are
marked as "always_inline" and "warn_unused_result".
Also, gcc 4.5 and 4.4 seem to compile these kind of functions used in P99 just
fine, but when putting a printf/snprintf in the "__cyg_profile*" functions
there is a memmory corruption.
With all gcc versions, when compiling without "-finstrument-functions" it works
just fine (and it seems valgrind doesn't find anything wrong either).
If you want me to try/test something, or if I can help in any way, please let
me know :)
Thanks a lot,
Rodrigo
More information about the Gcc-bugs
mailing list