[PATCH] D70910: [compiler-rt] Add a critical section when flushing gcov counters

calixte via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 12 11:00:37 PST 2019


calixte added a comment.

@jfb, sorry I thought my commit message was clear enough.
So when coverage is enabled a call to `__gcov_flush` is inserted just before `fork`call:
https://github.com/llvm/llvm-project/blob/master/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp#L659
So if the parent process is forked in different threads then `__gcov_flush` is called from different threads.
And so different global variables are accessed asynchronously:
https://github.com/llvm/llvm-project/blob/master/compiler-rt/lib/profile/GCDAProfiling.c#L104-L108
Initially we saw crashes in our CI: https://bugzilla.mozilla.org/show_bug.cgi?id=1599436
The above test case leads to multiple errors: double-free, "cannot merge previous GCDA file..."
And in debbuging firefox, I saw `output_file == NULL` (https://github.com/llvm/llvm-project/blob/master/compiler-rt/lib/profile/GCDAProfiling.c#L603) where it mustn't.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70910/new/

https://reviews.llvm.org/D70910





More information about the llvm-commits mailing list