-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
"stack smashing detected" in PyCursesWindow_Box #71853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
When attempting to run |hg chistedit|, which uses the python curses module, I am getting *** stack smashing detected ***: /usr/bin/python terminated The problem is in PyCursesWindow_Box in _cursesmodule.c:
ch1 and ch2 are of type 'chtype', which is a 4-byte integer on my platform. (I am on a fresh install of Fedora 24 x86_64.) The format string 'l' is writing 8 bytes. It is hard to fit 8 bytes into a 4 byte variable. I scanned through the rest of the file. Most places are very careful about this; if needed, they'll parse into a 'long' temporary and then assign. But here's another one in PyCurses_UngetMouse:
event.bstate is of type mmask_t, which is also 4 bytes. I did not find any more in that file. % rpm -q python-libs |
I'm running now (successfully) with a simpler patch, just changing it to parse format 'i', but this patch is probably a bit safer. |
Thank you for your patch Steve. It is better to use PyCurses_ConvertToChtype() which is used for parsing all chtype arguments. |
The Python 2.7 backport (commit b694770) is wrong. The _curses module cannot be compiled anymore: Example of compilation errors: /home/haypo/prog/python/2.7/Modules/_cursesmodule.c: In function 'PyCursesWindow_Box':
/home/haypo/prog/python/2.7/Modules/_cursesmodule.c:649:39: warning: passing argument 1 of 'PyCurses_ConvertToChtype' from incompatible pointer type [-Wincompatible-pointer-types]
if (!PyCurses_ConvertToChtype(self, temp1, &ch1)) {
^~~~
/home/haypo/prog/python/2.7/Modules/_cursesmodule.c:195:1: note: expected 'PyObject * {aka struct _object *}' but argument is of type 'PyCursesWindowObject * {aka struct <anonymous> *}'
PyCurses_ConvertToChtype(PyObject *obj, chtype *ch)
^~~~~~~~~~~~~~~~~~~~~~~~
/home/haypo/prog/python/2.7/Modules/_cursesmodule.c:649:45: warning: passing argument 2 of 'PyCurses_ConvertToChtype' from incompatible pointer type [-Wincompatible-pointer-types]
if (!PyCurses_ConvertToChtype(self, temp1, &ch1)) {
^~~~~
/home/haypo/prog/python/2.7/Modules/_cursesmodule.c:195:1: note: expected 'chtype * {aka unsigned int *}' but argument is of type 'PyObject * {aka struct _object *}'
PyCurses_ConvertToChtype(PyObject *obj, chtype *ch)
^~~~~~~~~~~~~~~~~~~~~~~~
/home/haypo/prog/python/2.7/Modules/_cursesmodule.c:649:14: error: too many arguments to function 'PyCurses_ConvertToChtype'
if (!PyCurses_ConvertToChtype(self, temp1, &ch1)) {
^~~~~~~~~~~~~~~~~~~~~~~~
/home/haypo/prog/python/2.7/Modules/_cursesmodule.c:195:1: note: declared here
PyCurses_ConvertToChtype(PyObject *obj, chtype *ch)
^~~~~~~~~~~~~~~~~~~~~~~~ |
Thank you for catching this Victor. |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: