This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Possible assertion failures due to _ctypes.c's PyCData_reduce()
Type: crash Stage: resolved
Components: ctypes, Extension Modules Versions: Python 3.8, Python 3.7, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ZackerySpytz, christian.heimes, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2019-02-28 19:13 by ZackerySpytz, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 12106 merged ZackerySpytz, 2019-02-28 19:16
PR 12642 merged miss-islington, 2019-03-31 16:02
PR 12643 merged ZackerySpytz, 2019-03-31 16:33
Messages (8)
msg336866 - (view) Author: Zackery Spytz (ZackerySpytz) * (Python triager) Date: 2019-02-28 19:13
The PyBytes_FromStringAndSize() and PyObject_GetAttrString() calls in PyCData_reduce() are not checked for failure.
msg336867 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-02-28 20:26
Does not Py_BuildValue() check the argument for "N" for NULL?
msg336870 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2019-02-28 21:36
Yes, N and O accept NULL and pass the exception up the call stack. It's not a bug. https://docs.python.org/3/c-api/arg.html?highlight=py_buildvalue#c.Py_BuildValue
msg337009 - (view) Author: Zackery Spytz (ZackerySpytz) * (Python triager) Date: 2019-03-02 12:48
I'm sorry. I misunderstood the behavior of Py_BuildValue().
msg339099 - (view) Author: Zackery Spytz (ZackerySpytz) * (Python triager) Date: 2019-03-29 07:45
I again encountered an assertion failure that involved PyCData_reduce(). In that function, PyBytes_FromStringAndSize() may be evaluated before PyObject_GetAttrString(). If a MemoryError occurs in PyBytes_FromStringAndSize(), an assertion failure will occur in _PyType_Lookup() when PyObject_GetAttrString() is called.

The assertion failure occurs before the Py_BuildValue() call. Please reopen the issue and the PR.
msg339265 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-03-31 16:02
New changeset 5f2c50810a67982b0c80f6d3258fee3647f67005 by Serhiy Storchaka (Zackery Spytz) in branch 'master':
bpo-36150: Fix possible assertion failures due to _ctypes.c's PyCData_reduce(). (GH-12106)
https://github.com/python/cpython/commit/5f2c50810a67982b0c80f6d3258fee3647f67005
msg339271 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-03-31 17:14
New changeset a110817c080ca3c2f3262350b5d7e0c0582527e6 by Serhiy Storchaka (Zackery Spytz) in branch '2.7':
bpo-36150: Fix possible assertion failures due to _ctypes.c's PyCData_reduce(). (GH-12106) (GH-12643)
https://github.com/python/cpython/commit/a110817c080ca3c2f3262350b5d7e0c0582527e6
msg339272 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-03-31 17:15
New changeset 5e233951d931acc0e927100c51e9a27a2791b6a5 by Serhiy Storchaka (Miss Islington (bot)) in branch '3.7':
bpo-36150: Fix possible assertion failures due to _ctypes.c's PyCData_reduce(). (GH-12106) (GH-12642)
https://github.com/python/cpython/commit/5e233951d931acc0e927100c51e9a27a2791b6a5
History
Date User Action Args
2022-04-11 14:59:11adminsetgithub: 80331
2019-03-31 17:26:47serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-03-31 17:15:13serhiy.storchakasetmessages: + msg339272
2019-03-31 17:14:20serhiy.storchakasetmessages: + msg339271
2019-03-31 16:33:27ZackerySpytzsetpull_requests: + pull_request12575
2019-03-31 16:02:36miss-islingtonsetstage: patch review
pull_requests: + pull_request12574
2019-03-31 16:02:13serhiy.storchakasetmessages: + msg339265
2019-03-29 09:06:11serhiy.storchakasetstatus: closed -> open
resolution: not a bug -> (no value)
stage: resolved -> (no value)
2019-03-29 07:45:49ZackerySpytzsetmessages: + msg339099
2019-03-02 12:48:52ZackerySpytzsetmessages: + msg337009
2019-02-28 21:36:33christian.heimessetstatus: open -> closed

nosy: + christian.heimes
messages: + msg336870

resolution: not a bug
stage: patch review -> resolved
2019-02-28 20:26:54serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg336867
2019-02-28 19:16:27ZackerySpytzsetkeywords: + patch
stage: patch review
pull_requests: + pull_request12113
2019-02-28 19:13:41ZackerySpytzcreate