You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PyOS_ReadlineFunctionPointer violates PyMem_Malloc() API: the GIL is not hold #62405
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2013-06-13.21:20:09.230>created_at=<Date2013-06-13.21:02:17.440>labels= ['interpreter-core', 'library']
title='PyOS_ReadlineFunctionPointer violates PyMem_Malloc() API: the GIL is not hold'updated_at=<Date2013-06-13.22:07:58.879>user='https://github.com/vstinner'
The callback PyOS_ReadlineFunctionPointer (used to read a line from the standard input) must return a buffer allocated by PyMem_Malloc(), but PyOS_Readline() releases the GIL before calling PyOS_ReadlineFunctionPointer.
tok_nextc() calls PyOS_Readline() and calls PyMem_FREE() to release its result.
PyOS_ReadlineFunctionPointer should allocate memory using malloc(), not using PyMem_Malloc(). But PyOS_Readline() should copy the line into a buffer allocated by PyMem_Malloc() to keep backward compatibility.
Activity
vstinner commentedon Jun 13, 2013
The callback PyOS_ReadlineFunctionPointer (used to read a line from the standard input) must return a buffer allocated by PyMem_Malloc(), but PyOS_Readline() releases the GIL before calling PyOS_ReadlineFunctionPointer.
Simplified extract of PyOS_Readline():
tok_nextc() calls PyOS_Readline() and calls PyMem_FREE() to release its result.
PyOS_ReadlineFunctionPointer should allocate memory using malloc(), not using PyMem_Malloc(). But PyOS_Readline() should copy the line into a buffer allocated by PyMem_Malloc() to keep backward compatibility.
See also issue bpo-18203 and bpo-3329.
vstinner commentedon Jun 13, 2013
Here is a patch for Python 3.4.
vstinner commentedon Jun 13, 2013
Oh, this is a duplicate of bpo-16742, read also the thread on python-dev:
http://mail.python.org/pipermail/python-dev/2012-December/123225.html