]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-6721: Hold logging locks across fork() (GH-4071) (#9291)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 7 Oct 2018 07:09:59 +0000 (00:09 -0700)
committerGregory P. Smith <greg@krypto.org>
Sun, 7 Oct 2018 07:09:59 +0000 (00:09 -0700)
commit3b699932e5ac3e76031bbb6d700fbea07492641d
tree40b092f6766719d4ce171d5d7d3cd0e92b44615a
parent1a2189353f744f79a43511707c090c3807a4978e
bpo-6721: Hold logging locks across fork() (GH-4071) (#9291)

bpo-6721: When os.fork() was called while another thread holds a logging lock, the child process may deadlock when it tries to log.  This fixes that by acquiring all logging locks before fork and releasing them afterwards.

A regression test that fails before this change is included.

Within the new unittest itself: There is a small _potential_ due to mixing of fork and a thread in the child process if the parent's thread happened to hold a non-reentrant library call lock (malloc?) when the os.fork() happens.  buildbots and time will tell if this actually manifests itself in this test or not.  :/  A functionality test that avoids that would be a challenge.

An alternate test that isn't trying to produce the deadlock itself but just checking that the release and acquire calls are made would be the next best alternative if so.
(cherry picked from commit 19003841e965bbf56fd06824d6093620c1b66f9e)

Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google]
Lib/logging/__init__.py
Lib/test/test_logging.py
Misc/NEWS.d/next/Library/2018-09-13-10-09-19.bpo-6721.ZUL_F3.rst [new file with mode: 0644]