cpython: fd8dc3746992 (original) (raw)

Mercurial > cpython

changeset 71128:fd8dc3746992

Merge 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 14:43:11 +0200
parents 775356b583d1(current diff)37606505b227(diff)
children 6b3872a11299
files Lib/test/test_multiprocessing.py Misc/NEWS
diffstat 3 files changed, 60 insertions(+), 6 deletions(-)[+] [-] Lib/multiprocessing/heap.py 39 Lib/test/test_multiprocessing.py 24 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 @@ -1721,6 +1721,8 @@ class _TestHeap(BaseTestCase): # verify the state of the heap all = [] occupied = 0

@@ -1738,6 +1740,28 @@ class _TestHeap(BaseTestCase): self.assertTrue((arena != narena and nstart == 0) or (stop == nstart))

+

+ # # #

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