classification
Title: possible null pointer dereference in pystate.c
Type: crash Stage: resolved
Components: Interpreter Core Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Mark.Shannon, eric.snow, pablogsal, vstinner
Priority: normal Keywords: patch

Created on 2018-08-14 20:09 by pablogsal, last changed 2019-05-10 21:31 by vstinner. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 8767 merged pablogsal, 2018-08-14 20:11
PR 13237 merged pablogsal, 2019-05-10 19:55
Messages (7)
msg323538 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2018-08-14 20:09
The problem occurs here:

https://github.com/python/cpython/blob/master/Python/pystate.c#L185

If _PyRuntime.interpreters.next_id < 0 then interp is set to NULL and it will be dereferenced later:

interp
msg324444 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2018-08-31 21:49
New changeset 95d630e2213fb0ffc197ec440efa3ae3dbb74f8d by Pablo Galindo in branch 'master':
bpo-34408: Prevent a null pointer dereference and resource leakage in `PyInterpreterState_New()` (GH-8767)
https://github.com/python/cpython/commit/95d630e2213fb0ffc197ec440efa3ae3dbb74f8d
msg341780 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2019-05-07 17:11
Any reason not to close this issue?
msg342040 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-05-10 02:07
> Any reason not to close this issue?

Pablo: Do you want to backport your fix to Python 3.7? Python 3.7 has the same bug, no? (I didn't check.)
msg342127 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2019-05-10 20:16
New changeset 34ed40f2e56703de04241cbacb306113b59a84f9 by Pablo Galindo in branch '3.7':
[3.7] bpo-34408: Prevent a null pointer dereference and resource leakage in `PyInterpreterState_New()` (GH-8767) (GH-13237)
https://github.com/python/cpython/commit/34ed40f2e56703de04241cbacb306113b59a84f9
msg342128 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2019-05-10 20:16
I have backported the fix to 3.7 :)
msg342137 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-05-10 21:31
> I have backported the fix to 3.7 :)

Ok, thanks.
History
Date User Action Args
2019-05-10 21:31:16vstinnersetmessages: + msg342137
2019-05-10 20:16:48pablogsalsetstatus: open -> closed
resolution: fixed
messages: + msg342128

stage: patch review -> resolved
2019-05-10 20:16:25pablogsalsetmessages: + msg342127
2019-05-10 19:55:08pablogsalsetpull_requests: + pull_request13147
2019-05-10 02:07:33vstinnersetmessages: + msg342040
2019-05-07 17:11:12Mark.Shannonsetnosy: + Mark.Shannon
messages: + msg341780
2018-08-31 21:49:38pablogsalsetmessages: + msg324444
2018-08-17 17:57:33steve.dowersetnosy: + vstinner, eric.snow
2018-08-14 20:11:14pablogsalsetkeywords: + patch
stage: patch review
pull_requests: + pull_request8243
2018-08-14 20:09:38pablogsalcreate