[issue9787] Release the TLS lock during allocations
Kristján Valur Jónsson
report at bugs.python.org
Tue Sep 7 08:03:06 CEST 2010
New submission from Kristján Valur Jónsson <kristjan at ccpgames.com>:
Holding the "keymutex" lock during malloc and free operations is not a good idea. The reason is, that custom implementations of malloc and free, can use the TLS themselves. This is, for example, true in embedded situations, where one wants to replace malloc with, e.g. appMalloc, (to monitor the memory useage of Python) and appMalloc itself uses python TLS to find the current python State.
This change makes the malloc and free calls outside the lock. The change in PyThread_set_key_value, requiring an extra lock allocate, has no significant performance impact since this is a rare api.
components: Interpreter Core
keywords: patch, patch
title: Release the TLS lock during allocations
versions: Python 3.2
Added file: http://bugs.python.org/file18782/tlspatch.patch
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list