This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: dict reentrant/threading request
Type: enhancement Stage: resolved
Components: Interpreter Core Versions: Python 3.2
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: Rhamphoryncus, gregory.p.smith, vstinner
Priority: normal Keywords:

Created on 2007-06-13 22:32 by Rhamphoryncus, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg32322 - (view) Author: Adam Olsen (Rhamphoryncus) Date: 2007-06-13 22:32
As I first mentioned in my post[1] on comp.lang.python, it seems possible to modify a dict while a lookup is ongoing, without causing the lookup to restart.  This requires the ma_table be reallocated twice (first to a new address, then a second time back to the original address).  This could also happen if the constants or behaviour relating to ma_smalltable were changed, but the current implementation is safe.

To fix this, I suggest two more tests be added along side the ep0 and startkey tests that currently restart the lookup process.

1) ma_mask.  If ma_table was reallocated, and the new allocation is smaller, memory corruption would result.  Checking ma_mask for changes would ensure this doesn't happen.

2) reallocation counter.  Increment every time ma_table is reallocated.  It would be technically possible to overflow this, but the circumstances would be exceedingly unusual.


[1] http://groups.google.com/group/comp.lang.python/browse_thread/thread/7f5b8fc59aadbdea/d77bdbcf5b20c056
msg116691 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-09-17 17:35
Is this something that should be taken up on python-dev?
msg116728 - (view) Author: Adam Olsen (Rhamphoryncus) Date: 2010-09-17 22:36
I don't believe there's anything to debate on this, so all it really needs is a patch, followed by getting someone to review and commit it.
msg402681 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-09-26 21:17
> As I first mentioned in my post[1] on comp.lang.python, it seems possible to modify a dict while a lookup is ongoing, without causing the lookup to restart.

That's a bad practice. Python dict raises an exception in some cases: RuntimeError("dict mutated during update").

Detecting any change during a lookup would slow down, whereas dict performance is key in Python performance in general, since dict is used everywhere for Python namespaces.

I close the issue as "wont fix".
History
Date User Action Args
2022-04-11 14:56:24adminsetgithub: 45091
2021-09-26 21:17:13vstinnersetstatus: open -> closed

nosy: + vstinner
messages: + msg402681

resolution: wont fix
stage: test needed -> resolved
2014-02-03 19:43:02BreamoreBoysetnosy: - BreamoreBoy
2010-09-17 22:36:33Rhamphoryncussetmessages: + msg116728
2010-09-17 17:35:51BreamoreBoysetnosy: + BreamoreBoy
messages: + msg116691
2010-07-10 11:53:26BreamoreBoysettitle: dict reentrant/threading bug -> dict reentrant/threading request
versions: - Python 2.7
2009-05-15 02:08:42ajaksu2setstage: test needed
versions: + Python 2.7, Python 3.2, - Python 2.6, Python 3.0
2008-01-17 01:35:08gregory.p.smithsetnosy: + gregory.p.smith
2008-01-06 12:33:29christian.heimessettype: enhancement
components: + Interpreter Core, - None
versions: + Python 2.6, Python 3.0
2007-06-13 22:32:25Rhamphoryncuscreate