HomePhabricator

Fix simultaneous .gcda creation

Authored by kawashima-fj on Mar 13 2020, 5:54 AM.

Description

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

Details

Committed
kawashima-fjMar 31 2020, 6:29 PM
Differential Revision
D76206: [gcov] Fix simultaneous .gcda creation
Parents
rG3341dc733996: [Driver] Don't pass -fobjc-rumtime= for non-ObjC input
Branches
Unknown
Tags
Unknown