This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug gcov-profile/68080] gcov returns negative counts
- From: "marxin at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 25 Jul 2016 08:07:21 +0000
- Subject: [Bug gcov-profile/68080] gcov returns negative counts
- Auto-submitted: auto-generated
- References: <bug-68080-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68080
--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
Well, the test-case is very interesting as it exposes 2 issues:
1) Majority of instrumented profiling code is not thread-safe, for instance
edge profiler:
PROF_edge_counter_11 =
__gcov0._ZL20__gthread_mutex_lockP15pthread_mutex_t[0];
PROF_edge_counter_12 = PROF_edge_counter_11 + 1;
__gcov0._ZL20__gthread_mutex_lockP15pthread_mutex_t[0] =
PROF_edge_counter_12;
2) As the test-case does not properly join created threads and original thread
reaches gcov_exit, we get messed profile. One thread is writing to disk while
the others are still modifying counters.
I'm going to discuss the aforementioned problem on GCC mailing list.