[issue43441] mutilcorevm: global variable next_version_tag cause method cache bug
junyixie
report at bugs.python.org
Mon Mar 8 22:54:44 EST 2021
New submission from junyixie <xie.junyi at outlook.com>:
type->tp_version_tag = next_version_tag++;
when sub interpreters parallel, next_version_tag++ is thread-unsafe. may cause different type has same tp_version_tag.
cause method cache bug in _PyType_Lookup
#define MCACHE_HASH_METHOD(type, name) \
MCACHE_HASH((type)->tp_version_tag, \
((PyASCIIObject *)(name))->hash)
if (MCACHE_CACHEABLE_NAME(name) &&
_PyType_HasFeature(type, Py_TPFLAGS_VALID_VERSION_TAG)) {
/* fast path */
unsigned int h = MCACHE_HASH_METHOD(type, name);
struct type_cache *cache = get_type_cache();
struct type_cache_entry *entry = &cache->hashtable[h];
if (entry->version == type->tp_version_tag && entry->name == name) {
#if MCACHE_STATS
cache->hits++;
#endif
return entry->value;
}
}
static int
assign_version_tag(struct type_cache *cache, PyTypeObject *type)
{
...
type->tp_version_tag = next_version_tag++;
...
}
----------
components: Interpreter Core
messages: 388327
nosy: JunyiXie
priority: normal
severity: normal
status: open
title: mutilcorevm: global variable next_version_tag cause method cache bug
versions: Python 3.10
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43441>
_______________________________________
More information about the Python-bugs-list
mailing list