Bug 38292 - [4.5/4.6/4.7/4.8 Regression] corrupted profile info with -O[23] -fprofile-use
Summary: [4.5/4.6/4.7/4.8 Regression] corrupted profile info with -O[23] -fprofile-use
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: gcov-profile (show other bugs)
Version: 4.4.0
: P2 normal
Target Milestone: 4.5.4
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2008-11-27 16:57 UTC by Matthias Klose
Modified: 2012-06-27 12:10 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.3.4, 4.4.0
Last reconfirmed: 2011-01-08 15:32:01


Attachments
thread.c source file (3.76 KB, text/x-chdr)
2009-02-12 14:06 UTC, Matthias Klose
Details
thread_pthread.h header (3.56 KB, text/x-chdr)
2009-02-12 14:09 UTC, Matthias Klose
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Klose 2008-11-27 16:57:42 UTC
seen with a profiled build (make profile-opt PROFILE_TASK='$(srcdir)/Lib/test/regrtest.py') building python-3.0rc3 on i486-linux-gnu. Using pybench as the PROFILE_TASK doesn't show this bug). Seen PR22471, but this one was reported long ago. What other information should be provided for this kind of report?

gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -O2 -Wall -Wstrict-prototypes  -fprofile-use -I. -IInclude -I../Include   -DPy_BUILD_CORE -o Modules/config.o Modules/config.c
../Python/thread.c: In function 'PyThread_acquire_lock':
../Python/thread.c:419: error: corrupted profile info: number of executions for edge 16-3 thought to be -1
../Python/thread.c:419: error: corrupted profile info: number of executions for edge 16-17 thought to be 5657524
make[3]: *** [Python/thread.o] Error 1
Comment 1 Jakub Jelinek 2009-02-04 19:51:13 UTC
Subject: Bug 38292

Author: jakub
Date: Wed Feb  4 19:50:58 2009
New Revision: 143937

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143937
Log:
	PR tree-optimization/38977
	PR gcov-profile/38292
	* calls.c (special_function_p): Disregard __builtin_
	prefix.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/calls.c

Comment 2 Matthias Klose 2009-02-12 13:04:21 UTC
still seen with a backport of the patch to the 4.3 branch and with trunk 20090211 on amd64. works on i486.

gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -fprofile-use -I. -IInclude -I../Include   -DPy_BUILD_CORE -o Modules/config.o Modules/config.c
../Python/thread.c: In function 'PyThread_acquire_lock':
../Python/thread.c:423: error: corrupted profile info: profile data is not flow-consistent
../Python/thread.c:423: error: corrupted profile info: number of executions for edge 16-3 thought to be -7
../Python/thread.c:423: error: corrupted profile info: number of executions for edge 16-17 thought to be 4920917
Comment 3 Richard Biener 2009-02-12 13:59:44 UTC
Can you check if moving the PR38977 fix to special_function_p (handling
plain fork there) fixes it?  What is the contents of thread.c?
Comment 4 Matthias Klose 2009-02-12 14:06:19 UTC
Created attachment 17286 [details]
thread.c source file
Comment 5 Matthias Klose 2009-02-12 14:09:39 UTC
Created attachment 17287 [details]
thread_pthread.h header
Comment 6 Matthias Klose 2009-02-12 15:40:13 UTC
a build with the suggested change doesn't show any change.

--- gcc/calls.c~        2009-02-05 09:30:24.000000000 +0100
+++ gcc/calls.c 2009-02-12 15:17:08.000000000 +0100
@@ -530,6 +530,8 @@
        }
       else if ((tname[0] == 'q' && tname[1] == 's'
                && ! strcmp (tname, "qsetjmp"))
+              || (tname[0] == 'f' && tname[1] == 'o'
+                  && ! strcmp (tname, "fork"))
               || (tname[0] == 'v' && tname[1] == 'f'
                   && ! strcmp (tname, "vfork"))
               || (tname[0] == 'g' && tname[1] == 'e'
Comment 7 Matthias Klose 2009-02-14 09:08:38 UTC
seen as well on sparc-linux, x86_64-linux and i486-linux (when built with -mcpu=i686 -mtune=i586), although triggered in different files.
Comment 8 Matthias Klose 2009-07-24 14:37:56 UTC
same behaviour with the 4.4.1 release
Comment 9 Richard Biener 2009-08-04 12:29:35 UTC
GCC 4.3.4 is being released, adjusting target milestone.
Comment 10 Richard Biener 2010-05-22 18:12:49 UTC
GCC 4.3.5 is being released, adjusting target milestone.
Comment 11 Jan Hubicka 2011-01-08 15:32:01 UTC
Richard's reorg of profiling to SSA uncovered some of issues with pure&const functions that are fixed in the current mainline. Can you, please, check if that solves your problem?
Comment 12 Matthias Klose 2011-01-10 17:24:03 UTC
I ran into bug #47248 trying to build a recent snapshot.
Comment 13 Matthias Klose 2011-01-19 11:43:30 UTC
trying to build python 3.2~rc1, I run into:

I get (with the just built python (built with -fprofile-generate):

build-static$ ./python
XXX lineno: 1101, opcode: 0
Fatal Python error: Py_Initialize: Unable to get the locale encoding
Traceback (most recent call last):
  File "/home/packages/python/3.2/python3.2-3.2~rc1/build-static/../Lib/encodings/__init__.py", line 31, in <module>
XXX lineno: 39, opcode: 0
Aborted

The build is ok with the normal build.
Comment 14 Matthias Klose 2011-01-19 11:53:54 UTC
no, normal python build fails too, this is reported as bug #47271.
Comment 15 Matthias Klose 2011-01-25 05:21:24 UTC
hmm, can't set the status back to NEW, just to RESOLVED. ...

a normal build of 3.2rc1 succeeds with trunk r169142 and the proposed fix for PR47271.

the profiled build still fails with:


gcc-4.6 -pthread -c  -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -fprofile-use  -I. -IInclude -I../Include    -DPy_BUILD_CORE -o Python/bltinmodule.o ../Python/bltinmodule.c
../Python/bltinmodule.c: In function 'builtin___build_class__':
../Python/bltinmodule.c:40:23: warning: variable 'nbases' set but not used [-Wunused-but-set-variable]
../Python/bltinmodule.c: In function 'builtin_exec':
../Python/bltinmodule.c:769:9: warning: variable 'plain' set but not used [-Wunused-but-set-variable]
gcc-4.6 -pthread -c  -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -fprofile-use  -I. -IInclude -I../Include    -DPy_BUILD_CORE -o Python/ceval.o ../Python/ceval.c
../Python/ceval.c: In function 'PyEval_RestoreThread':
../Python/ceval.c:4472:1: error: corrupted profile info: profile data is not flow-consistent
../Python/ceval.c:4472:1: error: corrupted profile info: number of executions for edge 4-5 thought to be 2002859
../Python/ceval.c:4472:1: error: corrupted profile info: number of executions for edge 4-1 thought to be -9
make[3]: *** [Python/ceval.o] Error 1
Comment 16 Manuel López-Ibáñez 2011-01-25 09:20:23 UTC
(In reply to comment #15)
> hmm, can't set the status back to NEW, just to RESOLVED. ...
> 

You have to use your gcc account (I think).
Comment 17 Richard Biener 2011-06-27 12:12:17 UTC
4.3 branch is being closed, moving to 4.4.7 target.
Comment 18 Andrew Pinski 2011-08-24 20:50:52 UTC
I don't think this is a regression now as we never had good thread support for gcov/profiling.  That is we don't do atomic adds for the profiling.
Comment 19 Richard Biener 2012-01-16 12:25:26 UTC
We seem to miss a reproducer here.
Comment 20 Jakub Jelinek 2012-03-13 12:45:03 UTC
4.4 branch is being closed, moving to 4.5.4 target.
Comment 21 Matthias Klose 2012-06-27 12:10:26 UTC
the python builds works when built using -fprofile-correction