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: Add error checks to PyInit_signal()
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: berker.peksag, christian.heimes, nanjekyejoannah, vstinner
Priority: normal Keywords: patch

Created on 2015-04-19 19:28 by christian.heimes, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
signalmodule.patch christian.heimes, 2015-04-19 19:28 review
Pull Requests
URL Status Linked Edit
PR 12765 merged nanjekyejoannah, 2019-04-10 17:38
Messages (6)
msg241551 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2015-04-19 19:28
The init function of the signal module fails to check for errors in a couple of places. The patch replaces PyDict_SetItemString() calls with PyModule_AddIntMacro() and error checks. An exception is unlikely so I'm OK when the patch just lands in 3.4 and 3.5.

CID 1295026 (#41 of 41): Dereference null return value (NULL_RETURNS)
dereference: Dereferencing a pointer that might be null x when calling PyDict_SetItemString
msg323669 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2018-08-17 20:42
All of the PyModule_AddIntMacro() changes have already been applied in https://github.com/python/cpython/commit/6782b14bcba612e4a39e41992c77306217b91e30.

The remaining parts are:

-    x = PyLong_FromLong((long)NSIG);
-    if (!x || PyDict_SetItemString(d, "NSIG", x) < 0)
+    if (PyModule_AddIntMacro(m, NSIG))
         goto finally;
-    Py_DECREF(x);

---

-     PyExc_IOError, NULL);
-    if (ItimerError != NULL)
-    PyDict_SetItemString(d, "ItimerError", ItimerError);
+                                     PyExc_IOError, NULL);
+    if (PyModule_AddObject(m, "ItimerError", ItimerError))
+        goto finally;
msg339990 - (view) Author: Joannah Nanjekye (nanjekyejoannah) * (Python committer) Date: 2019-04-11 18:02
@berkerpeksag I made the requested changes on the PR. PTAL.
msg340627 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2019-04-22 01:47
New changeset 9541bd321a94f13dc41163a5d7a1a847816fac84 by Berker Peksag (Joannah Nanjekye) in branch 'master':
bpo-24011: Use PyModule_Add{Object,IntMacro} in PyInit__signal() (GH-12765)
https://github.com/python/cpython/commit/9541bd321a94f13dc41163a5d7a1a847816fac84
msg340628 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2019-04-22 01:49
Thank you, Joannah. There's no need to backport PR 12765 to maintenance branches, so I'm closing this issue as 'fixed'.
msg351251 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-09-06 13:48
There is a regression related to reference count: see bpo-38037.
History
Date User Action Args
2022-04-11 14:58:15adminsetgithub: 68199
2019-09-06 13:48:35vstinnersetnosy: + vstinner
messages: + msg351251
2019-04-22 01:49:13berker.peksagsetstatus: open -> closed
versions: - Python 3.7
messages: + msg340628

resolution: fixed
stage: patch review -> resolved
2019-04-22 01:47:09berker.peksagsetmessages: + msg340627
2019-04-11 18:02:53nanjekyejoannahsetnosy: + nanjekyejoannah
messages: + msg339990
2019-04-10 17:38:02nanjekyejoannahsetstage: needs patch -> patch review
pull_requests: + pull_request12693
2019-04-10 13:49:42cheryl.sabellasetstage: patch review -> needs patch
versions: + Python 3.7, Python 3.8, - Python 3.4, Python 3.5
2018-08-17 20:42:31berker.peksagsetnosy: + berker.peksag
messages: + msg323669
2015-04-19 19:28:15christian.heimescreate