Title: _PyImport_ReInitLock() doesn't check return value of PyThread_acquire_lock
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.2, Python 3.3
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: brett.cannon Nosy List: brett.cannon, christian.heimes, eric.snow, jcea
Priority: normal Keywords:

Created on 2012-09-09 22:23 by christian.heimes, last changed 2012-11-16 02:41 by brett.cannon. This issue is now closed.

Messages (2)
msg170141 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2012-09-09 22:23
Coverity claims that the call to PyThread_acquire_lock with NOWAIT_LOCK can fail. It sounds plausible as you don't wait for the lock to succeed.

CID 486861: Unchecked return value (CHECKED_RETURN)At (3): Calling function "PyThread_acquire_lock(PyThread_type_lock, int)" without checking return value (as is done elsewhere 22 out of 23 times).
At (9): No check of the return value of "PyThread_acquire_lock(import_lock, 0)".
 205        PyThread_acquire_lock(import_lock, 0);
 206        /* XXX: can the previous line fail? */

By the way the code would be more readable with NOWAIT_LOCK instead of 0.
msg175665 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2012-11-16 02:41
The chances of this being a problem is REALLY small and the single function that calls this is a public void function so there is no way for an exception to propagate short of a fatal error which seems a bit much.

I did change to using NOWAIT_LOCK, though.
Date User Action Args
2012-11-16 02:41:30brett.cannonsetstatus: open -> closed
resolution: wont fix
messages: + msg175665

stage: resolved
2012-11-13 06:01:27eric.snowsetnosy: + eric.snow
2012-09-10 02:25:39jceasetnosy: + jcea
2012-09-09 22:23:13christian.heimescreate