classification
Title: unchecked return value in C OrderedDict
Type: crash Stage: resolved
Components: Library (Lib) Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: eric.snow Nosy List: Arfrever, eric.snow, python-dev, skrah, yselivanov
Priority: release blocker Keywords:

Created on 2015-06-01 16:19 by eric.snow, last changed 2015-06-02 05:07 by eric.snow. This issue is now closed.

Files
File name Uploaded Description Edit
crash-1.py eric.snow, 2015-06-01 16:19
issue24347.dif eric.snow, 2015-06-02 01:08
Messages (4)
msg244597 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2015-06-01 16:19
(from msg244574 in issue16991)

crash-1.py is due to an unchecked return value from _odictnode_VALUE().

We should probably use PyDict_GetItemWithError(), also in other
places.

I normally try to steer clear of stylistic remarks, but the
_odictnode* macros are hiding too many things.  As of now,
they were hiding that an assert() is always true and that a
return value was unchecked.

Also, they're very inconvenient in a debugger.
msg244604 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2015-06-01 17:17
Regarding the macros, my intent was to limit leaking the details of the linked list implementation and make it easier to change the linked list implementation later.  However, if that results in problems then I'm open to changing it.  What would you recommend?
msg244627 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2015-06-02 01:08
Using PyDict_GetItemWithError() is a good idea.  Also, raising KeyError when the value is NULL (and no errors set) eliminates the crash.  Here's a patch that fixes the problem.  Unless there are any objections, I'll commit it in a couple hours.
msg244649 - (view) Author: Roundup Robot (python-dev) Date: 2015-06-02 05:06
New changeset 1a7c34e23ec9 by Eric Snow in branch '3.5':
Issue #24347: Set KeyError if PyDict_GetItemWithError returns NULL.
https://hg.python.org/cpython/rev/1a7c34e23ec9
History
Date User Action Args
2015-06-02 05:07:09eric.snowsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2015-06-02 05:06:37python-devsetnosy: + python-dev
messages: + msg244649
2015-06-02 01:12:07eric.snowlinkissue24349 superseder
2015-06-02 01:08:20eric.snowsetfiles: + issue24347.dif

messages: + msg244627
stage: test needed -> patch review
2015-06-01 17:23:20Arfreversetnosy: + Arfrever
2015-06-01 17:17:54eric.snowsetmessages: + msg244604
2015-06-01 16:27:23yselivanovsetnosy: + yselivanov
2015-06-01 16:19:10eric.snowcreate