Skip to content

gh-158203: fix crash when static extension type used from subinterpreter - #159095

Open
BHUVANSH855 wants to merge 2 commits into
python:mainfrom
BHUVANSH855:fix/gh-158203
Open

BHUVANSH855 wants to merge 2 commits into
python:mainfrom
BHUVANSH855:fix/gh-158203

Conversation

@BHUVANSH855

Copy link
Copy Markdown
Contributor

Fix a crash (SIGSEGV) when a static C extension type is used from a subinterpreter after the main interpreter has populated its method cache.

cache_slot() returned &type->_tp_cache for static non-heap types that lack _Py_TPFLAGS_STATIC_BUILTIN — a globally shared field. When a subinterpreter resized the cache, it freed the main interpreter's copy causing a use-after-free.

Fix: return NULL from cache_slot() for such types; all callers treat NULL as caching disabled.

Fixes gh-158203.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using a static extension type from an isolated subinterpreter crashes

1 participant