Skip to content

Instantly share code, notes, and snippets.

@devdanzin
Created March 18, 2026 10:07
Show Gist options
  • Select an option

  • Save devdanzin/edc4c140cb2eb4d3b64ce886b1bb1c65 to your computer and use it in GitHub Desktop.

Select an option

Save devdanzin/edc4c140cb2eb4d3b64ce886b1bb1c65 to your computer and use it in GitHub Desktop.
_interpretersmodule.c: SEGV during interpreter creation under OOM

_interpretersmodule.c: SEGV during interpreter creation under OOM

Summary

Multiple missing PyErr_NoMemory calls and NULL dereferences in _interpretersmodule.c under OOM conditions during interpreter creation.

Reproducer

import _testcapi, _interpreters
for n in range(1, 80):
    _testcapi.set_nomemory(n, 0)
    try:
        interp = _interpreters.create()
        _testcapi.remove_mem_hooks()
        _interpreters.destroy(interp)
        break
    except MemoryError:
        _testcapi.remove_mem_hooks()
    except:
        _testcapi.remove_mem_hooks()
# SIGSEGV: NULL dereference
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment