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
readline.set_completer_delims() doesn't play well with others #61491
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-05-06.19:55:03.730>created_at=<Date2013-02-24.17:32:42.580>labels= ['extension-modules', 'type-crash']
title="readline.set_completer_delims() doesn't play well with others"updated_at=<Date2013-05-06.19:55:03.729>user='https://bugs.python.org/bfroehle'
The readline.set_completer_delims doesn't play well with others because
it assumes that only it ever allocates or modifies the
rl_completer_word_break_characters buffer. If other programs modify this
value, for example changing it from heap allocated space to stack
allocated space, the results can be catastrophic.
Take, for example, R as another programs which changes the readline
completer strings. When an embedded R instance is initialized (say, using r2py) something similar to the following takes place::
As you might expect the next trip through readline.set_completer_delims
after initializing R will be catastrophic when we attempt to free a stack
allocate buffer.
I think we should consider modifying the readline.set_completer_delims
to store the allocated buffers in the module state::
Thanks for reporting this. Do you want to contribute a proper patch? You'll find instructions at http://docs.python.org/devguide/
bfroehle commented on May 5, 2013
bfroehlemannequin
MannequinAuthor
More actions
Patch attached. I implemented this by adding a 'static char *' which
holds the memory we allocate. I did not use the PyState machinery.
python-dev commented on May 6, 2013
python-devmannequin
Mannequin
More actions
New changeset 55c7295aca6c by Antoine Pitrou in branch '2.7':
Issue bpo-17289: The readline module now plays nicer with external modules or applications changing the rl_completer_word_break_characters global variable. http://hg.python.org/cpython/rev/55c7295aca6c
python-dev commented on May 6, 2013
python-devmannequin
Mannequin
More actions
New changeset df0afd3ebb70 by Antoine Pitrou in branch '3.3':
Issue bpo-17289: The readline module now plays nicer with external modules or applications changing the rl_completer_word_break_characters global variable. http://hg.python.org/cpython/rev/df0afd3ebb70
New changeset 0f65426009e2 by Antoine Pitrou in branch 'default':
Issue bpo-17289: The readline module now plays nicer with external modules or applications changing the rl_completer_word_break_characters global variable. http://hg.python.org/cpython/rev/0f65426009e2
Activity
bfroehle commentedon Feb 24, 2013
The
readline.set_completer_delimsdoesn't play well with others becauseit assumes that only it ever allocates or modifies the
rl_completer_word_break_characters buffer. If other programs modify this
value, for example changing it from heap allocated space to stack
allocated space, the results can be catastrophic.
To remind you, the function essentially works as:
where
break_charsis the user provided string.Take, for example, R as another programs which changes the readline
completer strings. When an embedded R instance is initialized (say, using
r2py) something similar to the following takes place::As you might expect the next trip through
readline.set_completer_delimsafter initializing R will be catastrophic when we attempt to free a stack
allocate buffer.
I think we should consider modifying the
readline.set_completer_delimsto store the allocated buffers in the module state::
This would prevent the segfault and memory leaks, and would render weird
hacks (like https://bitbucket.org/lgautier/rpy2/commits/408bae913653 in
the r2py code) unnecessary.
pitrou commentedon May 4, 2013
Thanks for reporting this. Do you want to contribute a proper patch? You'll find instructions at http://docs.python.org/devguide/
bfroehle commentedon May 5, 2013
Patch attached. I implemented this by adding a 'static char *' which
holds the memory we allocate. I did not use the PyState machinery.
python-dev commentedon May 6, 2013
New changeset 55c7295aca6c by Antoine Pitrou in branch '2.7':
Issue bpo-17289: The readline module now plays nicer with external modules or applications changing the rl_completer_word_break_characters global variable.
http://hg.python.org/cpython/rev/55c7295aca6c
python-dev commentedon May 6, 2013
New changeset df0afd3ebb70 by Antoine Pitrou in branch '3.3':
Issue bpo-17289: The readline module now plays nicer with external modules or applications changing the rl_completer_word_break_characters global variable.
http://hg.python.org/cpython/rev/df0afd3ebb70
New changeset 0f65426009e2 by Antoine Pitrou in branch 'default':
Issue bpo-17289: The readline module now plays nicer with external modules or applications changing the rl_completer_word_break_characters global variable.
http://hg.python.org/cpython/rev/0f65426009e2
pitrou commentedon May 6, 2013
Thanks for the patch! I made a variable name a bit shorter and also added some error checking on the strdup() result.