New submission from Jack Miller <j...@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) { PyObject *window; WINDOW *win; int y, x, width, rep_len, end_len, ret; char *message, *rep, *end; const char *m_enc, *r_enc, *e_enc; if(!PyArg_ParseTuple(args, "Oiiietetet", &window, &y, &x, &width, &m_enc, &message, &r_enc, &rep, &e_enc, &end)) return NULL; if (window != Py_None) win = ((PyCursesWindowObject *)window)->win; else 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 FreeBSD. 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: http://codezen.org/cgi-bin/gitweb.cgi?p=canto.git;a=blob;f=canto/widecurse.c;h=d8a259a66c85f5fa87d52045a643fc81beec8017;hb=HEAD ) 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 messages: 88220 nosy: themoken severity: normal status: open title: Curses segfaulting in FreeBSD/amd64 type: crash versions: Python 2.5 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6091> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com