Page MenuHomePhabricator

Please use GitHub pull requests for new patches. Phabricator shutdown timeline

[Profile] Avoid deadlock in multithreaded context when forking with coverage enabled
Needs ReviewPublic

Authored by calixte on Feb 5 2020, 9:54 AM.



When a program is forked with code coverage enabled, all the counters are flushed.
To avoid data race, a critical section has been added around __gcov_flush ( but when forking the mutex is just duplicated and if it was in a locked state (in the parent process) then it's locked in the child process which leads to a deadlock when the child is trying to flush counters.
This patch aims to initialize the mutex in the child process when forking.
So a custom fork (__gcov_fork) is called from instrumented code and the mutex is then initialized in the child process.

Event Timeline

calixte created this revision.Feb 5 2020, 9:54 AM
Herald added projects: Restricted Project, Restricted Project, Restricted Project. · View Herald TranscriptFeb 5 2020, 9:54 AM
Herald added subscribers: llvm-commits, Restricted Project, cfe-commits and 2 others. · View Herald Transcript