[all-commits] [llvm/llvm-project] 9180c1: Fix simultaneous .gcda creation

KAWASHIMA Takahiro via All-commits all-commits at lists.llvm.org
Tue Mar 31 18:31:20 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 9180c14fe4d7f9d6f65da8bc593cd61796fdc50a
      https://github.com/llvm/llvm-project/commit/9180c14fe4d7f9d6f65da8bc593cd61796fdc50a
  Author: KAWASHIMA Takahiro <t-kawashima at fujitsu.com>
  Date:   2020-04-01 (Wed, 01 Apr 2020)

  Changed paths:
    M compiler-rt/lib/profile/GCDAProfiling.c
    A compiler-rt/test/profile/Inputs/instrprof-gcov-parallel.driver.c
    A compiler-rt/test/profile/Inputs/instrprof-gcov-parallel.target.c
    A compiler-rt/test/profile/Posix/instrprof-gcov-parallel.test

  Log Message:
  -----------
  Fix simultaneous .gcda creation

The intent of the `llvm_gcda_start_file` function is that only
one process create the .gcda file and initialize it to be updated
by other processes later.

Before this change, if multiple processes are started simultaneously,
some of them may initialize the file because both the first and
second `open` calls may succeed in a race condition and `new_file`
becomes 1 in those processes. This leads incorrect coverage counter
values. This often happens in MPI (Message Passing Interface) programs.
The test program added in this change is a simple reproducer.

This change ensures only one process creates/initializes the file by
using the `O_EXCL` flag.

Differential Revision: https://reviews.llvm.org/D76206




More information about the All-commits mailing list