You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
functools.partial: changing p.keywords during the call's keyword merge overflows a stack buffer #161692
3.15bugs and security fixes3.16new features, bugs and security fixesextension-modulesC modules in the Modules dirtype-crashA hard crash of the interpreter, possibly with a core dump
In 3.15, partial_vectorcall merges the stored and the call keywords itself. It reads the size of p.keywords once, sizes its buffers from it, and then calls PyDict_Contains(p.keywords, key) for each call keyword. That lookup can run a key's __eq__, and p.keywords is the same, writable dict. The loop that follows writes one slot per item of the dict as it is now, with only a debug-build assert on the count.
Output on 3.15.2: *** stack smashing detected ***: terminated (SIGABRT). If __eq__ clears p.keywords instead, it segfaults; if it adds one key, a call keyword is silently dropped. 3.14 does not crash.
Cause: Modules/_functoolsmodule.c, partial_vectorcall: the keyword count is read once, PyDict_Contains(partial_keywords, key) in the merge loop can run Python code, and the PyDict_Next loop after it writes stack and the names tuple by index with no bound in a release build.
CPython versions tested on:
3.15, CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.15.2 (tags/v3.15.2:5e58eaa, Nov 5 2026, 20:20:36) [GCC 11.4.0]
Confirming this is a real issue; the proposed fix is functional but there's also some related issues such as gh-162774 which it leaves open. I'm proposing for 3.16 this moves to frozendict which another core developer @kumaraditya303 suggested in another chat. For 3.15 and below just adding appropriate Py_INCREF.
3.15bugs and security fixes3.16new features, bugs and security fixesextension-modulesC modules in the Modules dirtype-crashA hard crash of the interpreter, possibly with a core dump
Activity
[-]functools.partial: changing p.keywords during the call's keyword merge overflows a stack buffer (new in 3.15)[/-]cmaloney commentedon Nov 28, 2026
Confirming this is a real issue; the proposed fix is functional but there's also some related issues such as gh-162774 which it leaves open. I'm proposing for 3.16 this moves to frozendict which another core developer @kumaraditya303 suggested in another chat. For 3.15 and below just adding appropriate Py_INCREF.