Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
GH-99293: Fix stale method caches and assertion errors in SWIG-generated modules#99294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1 @@ | ||||||
Fix an issue where extension modules could inadvertently trigger an assertion error in typeobject.c by clearing the Py_TPFLAGS_VALID_VERSION_TAG tp_flag without clearing the tp_version_tag field. (Extension modules should use PyType_Modified() instead, however.) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I just noticed Suggested change
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -4176,12 +4176,17 @@ _PyType_Lookup(PyTypeObject *type, PyObject *name) | ||
unsigned int h = MCACHE_HASH_METHOD(type, name); | ||
struct type_cache *cache = get_type_cache(); | ||
struct type_cache_entry *entry = &cache->hashtable[h]; | ||
/* Some extension modules (e.g. those generated by SWIG) don't always | ||
* change/clear tp_version_tag when they clear the | ||
* Py_TPFLAGS_VALID_VERSION_TAG tp_flag, so check both tp_version_tag | ||
* and the tp_flag. (Invalidated cache entries are replaced below.) | ||
*/ | ||
if (entry->version == type->tp_version_tag && | ||
entry->name == name && | ||
_PyType_HasFeature(type, Py_TPFLAGS_VALID_VERSION_TAG)) { | ||
#if MCACHE_STATS | ||
cache->hits++; | ||
#endif | ||
return entry->value; | ||
} | ||
Member
| ||