From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10595 invoked by alias); 28 Jun 2013 15:25:46 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 10537 invoked by uid 48); 28 Jun 2013 15:25:41 -0000 From: "rodrigo at sdfg dot com.ar" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/52544] compilation fails with -finstrument-functions and sse c code Date: Fri, 28 Jun 2013 15:25:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 4.6.3 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rodrigo at sdfg dot com.ar X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-06/txt/msg01769.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52544 --- Comment #5 from Rodrigo Campos --- 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