cpython: 96a0788583c6 (original) (raw)

Mercurial > cpython

changeset 71124:96a0788583c6 2.7

Issue #12352: Fix a deadlock in multiprocessing.Heap when a block is freed by the garbage collector while the Heap lock is held. [#12352]

Charles-François Natali neologix@free.fr
date Sat, 02 Jul 2011 13:56:19 +0200
parents 45b27448f95c
children 874143242d79
files Lib/multiprocessing/heap.py Lib/test/test_multiprocessing.py Misc/NEWS
diffstat 3 files changed, 61 insertions(+), 6 deletions(-)[+] [-] Lib/multiprocessing/heap.py 39 Lib/test/test_multiprocessing.py 25 Misc/NEWS 3

line wrap: on

line diff

--- a/Lib/multiprocessing/heap.py +++ b/Lib/multiprocessing/heap.py @@ -101,6 +101,8 @@ class Heap(object): self._stop_to_block = {} self._allocated_blocks = set() self._arenas = []

@staticmethod def _roundup(n, alignment): @@ -175,15 +177,39 @@ class Heap(object): return start, stop

+ def free(self, block): # free a block returned by malloc()

def malloc(self, size): # return a block of right size (possibly rounded up) @@ -191,6 +217,7 @@ class Heap(object): if os.getpid() != self._lastpid: self.init() # reinitialize after fork self._lock.acquire()

--- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -1615,6 +1615,8 @@ class _TestHeap(BaseTestCase): # verify the state of the heap all = [] occupied = 0

@@ -1632,6 +1634,29 @@ class _TestHeap(BaseTestCase): self.assertTrue((arena != narena and nstart == 0) or (stop == nstart))

+

+ # # #

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -18,6 +18,9 @@ Core and Builtins Library ------- +- Issue #12352: Fix a deadlock in multiprocessing.Heap when a block is freed by