Message388327
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++;
...
} |
|
Date |
User |
Action |
Args |
2021-03-09 03:54:44 | JunyiXie | set | recipients:
+ JunyiXie |
2021-03-09 03:54:44 | JunyiXie | set | messageid: <1615262084.5.0.815014213556.issue43441@roundup.psfhosted.org> |
2021-03-09 03:54:44 | JunyiXie | link | issue43441 messages |
2021-03-09 03:54:44 | JunyiXie | create | |
|