FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-118608: datetime: Fix use-after-free on embedded CPython by neonene · Pull Request #118531 · python/cpython · GitHub

/ cpython Public

gh-118608: datetime: Fix use-after-free on embedded CPython - #118531

Closed
neonene wants to merge 9 commits into
python:mainfrom
neonene:statickey
Closed

gh-118608: datetime: Fix use-after-free on embedded CPython#118531
neonene wants to merge 9 commits into
python:mainfrom
neonene:statickey

Conversation

neonene commented May 3, 2024
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

Debug build on Windows (and CI: 7bbce38):

>_testembed_d test_repeated_init_exec "import datetime"
--- Loop #1 ---
--- Loop #2 ---
Assertion failed: PyUnicode_CheckExact(ep_key), file C:\a\Objects\dictobject.c, line 1119

At the Loop #2, the static types are carried over in the _datetime module, but their tp_dict no longer has valid keys, since all interned strings (keys) are freed after _PyUnicode_ClearInterned() in unicodeobject.c is invoked.

To check a key without a crash, the following strings need to be statically allocated:

  • The names in PyMemberDef array
  • The names in PyMethodDef array
  • The names in PyGetSetDef array
  • The key parameters of the PyDict_SetItemString(tp_dict, key, value) calls.

This patch includes the names that are already statically allocated (e.g. getset names).


bedevere-app Bot added the tests Tests in the Lib/test dir label May 3, 2024
neonene changed the title datetime: Fix use-after-free on embedded CPython gh-113055: datetime: Fix use-after-free on embedded CPython May 3, 2024
neonene marked this pull request as ready for review May 3, 2024 02:24
neonene requested review from abalkin and pganssle as code owners May 3, 2024 02:24
neonene changed the title gh-113055: datetime: Fix use-after-free on embedded CPython gh-118608: datetime: Fix use-after-free on embedded CPython May 5, 2024
neonene marked this pull request as draft May 5, 2024 20:04
neonene closed this May 23, 2024
neonene deleted the statickey branch May 23, 2024 14:21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL