New submission from junyixie <xie.ju...@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 <rep...@bugs.python.org> <https://bugs.python.org/issue43441> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com