Code coverage flush hangs forever when a content process exits while flushing (Linux/Android)
Categories
(Testing :: Code Coverage, defect)
Tracking
(Not tracked)
People
(Reporter: calixte, Assigned: calixte)
References
Details
Attachments
(1 external file)
Since the end-of-suite coverage dump from bug 2077159, Android ccov mochitest-plain chunks sometimes stop right after the last test of a directory: no SimpleTest FINISHED, then "application timed out after 370 seconds with no output" and a harness kill (libc.so + 0xb94da). The kill then also shows up as an unexpected crash dump in the next run.
Bug 2094313 fixes the case where the dying process makes the flush promise reject. This is a different case: no promise is ever rejected, some of the other processes never finish their flush and the parent waits forever for them.
Try push with the bug 2094313 patch: https://treeherder.mozilla.org/jobs?repo=try&revision=d2be31d1d92c41e0d9eaaf7b00e4388d6d5104f8
2 out of 3 Android ccov mochitest-plain jobs time out this way in dom/security/permissionspolicy/test/mochitest, right after test_parser.html passes. Logcat of task e5o8CFGfQkSH3Mc-6mx04w:
22:14:37.639 9922 [CodeCoverage] flush completed.
22:14:37.727 10182 [CodeCoverage] Requested flush for 10182.
22:14:37.727 10142 [CodeCoverage] Requested flush for 10142.
22:14:37.727 10035 [CodeCoverage] Requested flush for 10035.
22:14:37.732 10182 Destroying GeckoServiceChildProcess
22:14:37.734 10182 System.exit called, status: 0
10142 and 10035 never print "flush completed" and are still alive when the harness kills the app at 22:21. Task OXI3TZbbSwqR4xwdNziaDw shows the same pattern (10364 exits 9 ms after receiving the request, 10326 and 10219 never complete).
CodeCoverageHandler::FlushCounters takes a cross-process mutex around __gcov_dump. On POSIX, CrossProcessMutex is a PTHREAD_PROCESS_SHARED mutex that is not robust, so when a process exits while holding it (here, a content process being torn down right after the test removed the frame it was hosting), the mutex stays locked and every other process blocks in FlushCounters. Windows is not affected since a Win32 mutex is released when its owner dies.
A robust mutex is not an option: bionic has no pthread_mutexattr_setrobust.
The cross-process mutex was added in bug 1363469 because GCC's __gcov_dump and __gcov_reset were not protected by any lock, unlike __gcov_flush. Across processes, compiler-rt already serializes writers of a .gcda file itself: llvm_gcda_start_file locks each file (fcntl(F_SETLKW) or flock, since LLVM r234036 "profile: Protect .gcda output with flock"), and the kernel releases that lock when the process dies. The JS coverage .info files are named per pid. So the remaining need seems to be making the dump and reset atomic within a process (the SIGUSR1 handler vs. an IPC request), which an in-process mutex would cover, and the cross-process one along with the ShareCodeCoverageMutex message could go away. One thing to check first: that the Linux content sandbox in ccov builds lets the .gcda file lock through, otherwise compiler-rt silently skips it.
| Assignee | ||
Comment 1•10 days ago
|
||
A content process can exit while holding the shared mutex and leave every other process waiting. The coverage runtime already locks each .gcda file across processes, so each process can serialize its own dump and reset.
Updated•10 days ago
|
Updated•9 days ago
|
Description
•