Bug 1419196 - Use the "threadsafe" variant of gtest death tests. r=ted
Because the default "fast" variant uses fork() on !windows, death tests
are dangerous, as they themselves say. There are race conditions
involving locks that lead to dead locks in the death test process while
disabling the crash reporter (currently, but this could happen for
different code, even the tested code itself).
See https://bugzilla.mozilla.org/show_bug.cgi?id=1419196#c7 for details.
Using the "threadsafe" variant creates new processes for each death
test. This is notably slower, but can't dead-lock because of some random
lock being held by some random other thread at the moment fork occurred.
--- a/python/mozbuild/mozbuild/mach_commands.py
+++ b/python/mozbuild/mozbuild/mach_commands.py
@@ -553,17 +553,17 @@ class GTestCommands(MachCommandBase):
def gtest(self, shuffle, jobs, gtest_filter, tbpl_parser, debug, debugger,
debugger_args):
# We lazy build gtest because it's slow to link
self._run_make(directory="testing/gtest", target='gtest',
print_directory=False, ensure_exit_code=True)
app_path = self.get_binary_path('app')
- args = [app_path, '-unittest'];
+ args = [app_path, '-unittest', '--gtest_death_test_style=threadsafe'];
if debug or debugger or debugger_args:
args = self.prepend_debugger_args(args, debugger, debugger_args)
cwd = os.path.join(self.topobjdir, '_tests', 'gtest')
if not os.path.isdir(cwd):
os.makedirs(cwd)
--- a/testing/gtest/rungtests.py
+++ b/testing/gtest/rungtests.py
@@ -52,17 +52,18 @@ class GTests(object):
stream_output = mozprocess.StreamOutput(sys.stdout)
process_output = stream_output
if utility_path:
stack_fixer = get_stack_fixer_function(utility_path, symbols_path)
if stack_fixer:
process_output = lambda line: stream_output(stack_fixer(line))
- proc = mozprocess.ProcessHandler([prog, "-unittest"],
+ proc = mozprocess.ProcessHandler([prog, "-unittest",
+ "--gtest_death_test_style=threadsafe"],
cwd=cwd,
env=env,
processOutputLine=process_output)
#TODO: After bug 811320 is fixed, don't let .run() kill the process,
# instead use a timeout in .wait() and then kill to get a stack.
proc.run(timeout=GTests.TEST_PROC_TIMEOUT,
outputTimeout=GTests.TEST_PROC_NO_OUTPUT_TIMEOUT)
proc.wait()