Author vstinner
Recipients eric.snow, pablogsal, pitrou, vstinner
Date 2019-06-10.23:10:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1560208250.74.0.640234147344.issue36402@roundup.psfhosted.org>
In-reply-to
Content
test_threading: test_threads_join_2() was added by commit 7b47699 in 2013, but the test failed randomly since it was added. It's just that failures were ignored until I created https://bugs.python.org/issue36402 last March.

In fact, when the test failed randomly on buildbot (with tests run in parallel), it was fine since test_threading was re-run alone and then the test passed. The buildbot build was seen overall as a success. Previous issues were closed (see my previous comment).

The test shows the bug using subinterpreters (Py_EndInterpreter), but the bug also exists in Py_Finalize() which hash the same race condition (it also calls threading._shutdown()). It's just that Py_EndInterpreter() is stricter, it contains this assertion:

    if (tstate != interp->tstate_head || tstate->next != NULL)
        Py_FatalError("Py_EndInterpreter: not the last thread");

Attached py_finalize.patch adds the same assertion to Py_Finalize.

I added test_threading.test_finalization_shutdown() to PR 13948. If you run test_finalization_shutdown() with py_finalize.patch, Py_Finalize() fails with a similar assertion error.

But py_finalize.patch is incompatible with the principle of daemon threads and so cannot be commited.
History
Date User Action Args
2019-06-10 23:10:50vstinnersetrecipients: + vstinner, pitrou, eric.snow, pablogsal
2019-06-10 23:10:50vstinnersetmessageid: <1560208250.74.0.640234147344.issue36402@roundup.psfhosted.org>
2019-06-10 23:10:50vstinnerlinkissue36402 messages
2019-06-10 23:10:50vstinnercreate