Sorry for the vague description, but I haven't been able to track down exactly what causes this...
What appears to cause it is this function definition.
I figured this out through trial and error by rolling back commits and removing various lines. It seems that whenever that function and its parent function are both defined, coverage.py will segfault when running exactly that test. Moving the inner function to a different scope or renaming it seems not to change this.
None of that code actually runs in the test case, and it seems to only be an issue when the parent function is defined.
For the time being we have simply replaced that function with a non-recursive implementation, but it still seemed like a good idea to report this issue... Any idea what might be happening, or what could be done to further debug this?