GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||
GeezerVison is showing github.com — bpo-1635741: Fix unicode_dealloc() for mortal interned string by vstinner · Pull Request #21270 · python/cpython Conversation
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| PyDict_DelItem(). */ | ||
| assert(Py_REFCNT(unicode) == 0); | ||
| Py_SET_REFCNT(unicode, 3); | ||
| if (PyDict_DelItem(interned, unicode) != 0) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can we skip PyDict_DelItem() and set interned unicode's refcnt = 0 directly in here?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We cannot remove the PyDict_DelItem() call.
PyUnicode_InternInPlace() uses black magic: it ignores 2 references (key and value) of the interned dictionary.
We must remove the string from the interned dictionary. Otherwise, the dictionary will contain a dangling pointer when unicode_dealloc() completes: using the dict is likely to crash in this case.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
got it, make sense, thanks.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks victor's PR, LGTM :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Technically, this change is mostly a cleanup, since the object is destroyed anyway a few lines below. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.