[New-bugs-announce] [issue6091] Curses segfaulting in FreeBSD/amd64
report at bugs.python.org
Sat May 23 04:10:28 CEST 2009
New submission from Jack Miller <jack at codezen.org>:
I have some code that gets a Pycurses window object, grabs the standard
ncurses WINDOW* out of it and proceeds to use that as usual. Works great
on Linux. Segfaults on FreeBSD/amd64.
static PyObject * mvw(PyObject *self, PyObject *args)
int y, x, width, rep_len, end_len, ret;
char *message, *rep, *end;
const char *m_enc, *r_enc, *e_enc;
&window, &y, &x, &width, &m_enc, &message,
&r_enc, &rep, &e_enc, &end))
if (window != Py_None)
win = ((PyCursesWindowObject *)window)->win;
win = NULL;
Very simple. After this runs, `win` should be a standard curses window.
As noted, this works just fine in Linux regardless of architecture and
I'm sure that I'm passing a correct object type. (Tangentially, the
window check macro in py_curses.h -- PyCursesWindow_Check(v) -- also
segfaults, but I haven't tested that on Linux).
The subsequent `win` is non-NULL, but when I attempt to actually use it,
even for a simple `mvwaddch(win, 0, 0, '?');`, the program segfaults on
Other Notes: If I just use curses from Python (i.e. without a C
extension), it works as expected. I've attached this basic, working
test. This leads me to believe that the ncurses library is ok, and that
the majority of the curses binding is probably ok.
Also, I'm not sure if there is a better (more pythonic) way to get to
the WINDOW object, I just looked at the struct in py_curses.h to grab it
and it worked, so I didn't give it a second thought until now. I also
don't know how to verify that the pointer points to a curses WINDOW, but
I do know that the pointer address looks ok.
I can whip up a non-working test case on request, but I'm not sure the
best way to include the extension. The full source for the extension and
the program using it at codezen.org/canto ( particularly:
I'm running FreeBSD 8-CURRENT, but the code doesn't work on 7.2-STABLE
either. This is Python 2.5.4 and pyncurses 0.3 both built from source
out of ports as of May 20th.
components: Extension Modules
title: Curses segfaulting in FreeBSD/amd64
versions: Python 2.5
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce