classification
Title: PyImport_ReInitLock() doesn't check for allocation error
Type: behavior Stage: resolved
Components: Versions: Python 3.5, Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: christian.heimes Nosy List: brett.cannon, christian.heimes, python-dev
Priority: normal Keywords: buildbot, easy, patch

Created on 2015-04-18 22:42 by christian.heimes, last changed 2015-04-20 14:52 by christian.heimes. This issue is now closed.

Files
File name Uploaded Description Edit
import_reinit_fatal.patch christian.heimes, 2015-04-18 22:42 review
Messages (4)
msg241462 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2015-04-18 22:42
_PyImport_ReInitLock() doesn't check the return value of PyThread_allocate_lock(). A failed lock allocation can either lead to a NULL pointer dereference or to race conditions caused by a missing import lock.

As there is no way to recover from a failed lock allication I recommend to abort with a fatal error.

CID 1295025 (#1 of 1): Dereference after null check (FORWARD_NULL)
var_deref_model: Passing null pointer import_lock to PyThread_acquire_lock, which dereferences it.
msg241517 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2015-04-19 14:18
LGTM
msg241547 - (view) Author: Roundup Robot (python-dev) Date: 2015-04-19 19:15
New changeset d70995cf44b3 by Christian Heimes in branch '2.7':
Issue #23998: PyImport_ReInitLock() now checks for lock allocation error
https://hg.python.org/cpython/rev/d70995cf44b3

New changeset 7d7bf5c34d7e by Christian Heimes in branch '3.3':
Issue #23998: PyImport_ReInitLock() now checks for lock allocation error
https://hg.python.org/cpython/rev/7d7bf5c34d7e

New changeset e0bd083fc9c1 by Christian Heimes in branch '3.4':
Issue #23998: PyImport_ReInitLock() now checks for lock allocation error
https://hg.python.org/cpython/rev/e0bd083fc9c1

New changeset 7ae8fd62d743 by Christian Heimes in branch 'default':
Issue #23998: PyImport_ReInitLock() now checks for lock allocation error
https://hg.python.org/cpython/rev/7ae8fd62d743
msg241656 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2015-04-20 14:52
Thanks, Brett!
History
Date User Action Args
2015-04-20 14:52:14christian.heimessetstatus: open -> closed
resolution: fixed
messages: + msg241656

stage: commit review -> resolved
2015-04-19 19:15:52python-devsetnosy: + python-dev
messages: + msg241547
2015-04-19 14:18:02brett.cannonsetnosy: + brett.cannon
messages: + msg241517

assignee: christian.heimes
stage: patch review -> commit review
2015-04-18 22:42:35christian.heimescreate