https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82457

            Bug ID: 82457
           Summary: libgcov fork and exec hooks not always used
           Product: gcc
           Version: 5.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: gcov-profile
          Assignee: unassigned at gcc dot gnu.org
          Reporter: aschepler at gmail dot com
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

The gcc man page claims about the --coverage option that "'fork' calls are
detected and correctly handled (double counting will not happen)."  This is
apparently related to the hook function __gcov_fork in libgcov.  libgcov also
has some __gcov_execve and other __gcov_exec* hooks, which look to similarly
dump data to avoid losing it on an exec.

But these hooks are not always used when --coverage is specified.

Apparently when compiling with -std=c11 --coverage flag, a call to fork gets
translated to the ordinary library symbol fork, but when compiling with
-std=gnu11 --coverage, a call to fork gets translated as a call to the
__gcov_fork symbol instead.

(A StackOverflow question discussing all this:
https://stackoverflow.com/questions/46381406/libgcov-fork-and-exec-hooks )

It's not clear why these would act different, or what exactly determines
whether the hook replacement can happen or not.

If this is intentional for some reason, the documentation should be updated to
explain when fork double counts and exec count loss will and won't be avoided.

Reply via email to