--parallel=fork swallows exceptions during child process setup

Bug #804130 reported by Martin Packman
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Medium
Martin Packman

Bug Description

If any kind of exception happens prior to the test run in a child process when using --parallel=fork, rather than the exception being reported, subunit simply reports that 0 tests have been run.

This is down to the following code testtools.tests.fork_for_tests:

    if pid == 0:
        workaround_zealous_crypto_random()
        try:
            ...
        finally:
            os._exit(0)

Because os._exit(0) is called in all cases, the normal python error processing, which involves printing the traceback to stderr and setting a suitable return code, does not happen. And subunit takes this to mean a successful run of zero tests.

Do the old rules about calling _exit from child processes even apply in Python? It seems most of them are just assuming you screwed up the lifetime of all your file handles by inheriting the lot, which... is something bzr needs to fix anyway.

Tags: selftest

Related branches

Revision history for this message
Martin Pool (mbp) wrote :

I think I may have seen something like this cause a confusing error when there was a syntax error in code or similar only hit starting the child process.

I think fixing the handles to be close-on-exec where appropriate could be good. Also just having an 'except' block that prints an error and returns 1 would be cheap and worthwhile.

Changed in bzr:
status: New → Confirmed
importance: Undecided → Medium
Martin Packman (gz)
Changed in bzr:
assignee: nobody → Martin Packman (gz)
status: Confirmed → In Progress
Martin Packman (gz)
Changed in bzr:
milestone: none → 2.5b3
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.