python curses , segmentation fault on screen.addstr()

I have an application that's running curses on a weird linux environment... a lot of the base paths of stuff are non standard. But other screen applications run fine.

I've set TERMINFO_DIRS and gotten the ncurses application to run. Using a nonstandard terminfo path.

I see windows draw up fine, and when I remove addstr() function calls it runs properly... even keyboard interaction.

It goes to segmentation fault whenever I attempt to print string text to a window. ( screen.addstr() )

I thought it was a LOCALE issue, but I've been unable to make it work toggling environment vars. Also in strace I see the locale info loading just fine.

I compared my strace to an strace from top to see if I could spot any inconsistences and I saw nothing.

Here's a tail end of the strace output...

open("/usr/lib/locale/en_US/LC_TIME", O_RDONLY) = 3
fstat(3, {st_dev=makedev(104, 1), st_ino=42649592, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=2456, st_atime=2009/10/09-20:18:08, st_mtime=2007/09/12-17:11:21, st_ctime=2009/02/19-22:20:38}) = 0
mmap(NULL, 2456, PROT_READ, MAP_PRIVATE, 3, 0) = 0x2a96417000
close(3)                                = 0
open("/usr/lib/locale/en_US/LC_NUMERIC", O_RDONLY) = 3
fstat(3, {st_dev=makedev(104, 1), st_ino=42649589, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=59, st_atime=2009/10/09-20:18:08, st_mtime=2007/09/12-17:11:09, st_ctime=2009/02/19-22:20:38}) = 0
mmap(NULL, 59, PROT_READ, MAP_PRIVATE, 3, 0) = 0x2a96418000
close(3)                                = 0
futex(0x603b30, FUTEX_WAKE, 1)          = 0
futex(0x603b30, FUTEX_WAKE, 1)          = 0
futex(0x603b30, FUTEX_WAKE, 1)          = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {c_iflags=0x2506, c_oflags=0x5, c_cflags=0xbf, c_lflags=0x8a3b, c_line=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = 0
access("/home/user/.terminfo/v/vt100", R_OK) = -1 ENOENT (No such file or directory)
access("/opt/opsware/ogfsutils/share/terminfo/v/vt100", R_OK) = 0
open("/opt/opsware/ogfsutils/share/terminfo/v/vt100", O_RDONLY) = 3
read(3, "\32\1,\0&\0\7\0\16\1\"\2", 12) = 12
read(3, "vt100|vt100-am|dec vt100 (w/adva"..., 44) = 44
read(3, "\0\1\0\0\1\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0\1\0\1\0\0\0\0\0\0\0\0\0"..., 38) = 38
read(3, "P\0\10\0\30\0\377\377\377\377\377\377\3\0", 14) = 14
read(3, "\377\377\0\0\2\0\4\0\25\0\32\0&\0.\0\377\377\377\3777\0L\0N\0\377\377R\0\377\377"..., 540) = 540
read(3, "\7\0\r\0\33[%i%p1%d;%p2%dr\0\33[3g\0\33[H\33[J"..., 546) = 546
read(3, "", 10)                         = 0
close(3)                                = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {c_iflags=0x2506, c_oflags=0x5, c_cflags=0xbf, c_lflags=0x8a3b, c_line=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {c_iflags=0x2506, c_oflags=0x5, c_cflags=0xbf, c_lflags=0x8a3b, c_line=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {c_iflags=0x2506, c_oflags=0x5, c_cflags=0xbf, c_lflags=0x8a3b, c_line=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = 0
ioctl(1, TIOCGWINSZ, {ws_row=69, ws_col=153, ws_xpixel=0, ws_ypixel=0}) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {c_iflags=0x2506, c_oflags=0x5, c_cflags=0xbf, c_lflags=0x8a3b, c_line=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {c_iflags=0x2506, c_oflags=0x5, c_cflags=0xbf, c_lflags=0x8a3b, c_line=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {c_iflags=0x2506, c_oflags=0x5, c_cflags=0xbf, c_lflags=0x8a3b, c_line=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = 0
ioctl(1, SNDCTL_TMR_STOP or TCSETSW, {c_iflags=0x2406, c_oflags=0x5, c_cflags=0xbf, c_lflags=0x8a39, c_line=0, c_cc[VMIN]=1, c_cc[VTIME]=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = 0
ioctl(1, SNDCTL_TMR_STOP or TCSETSW, {c_iflags=0x2406, c_oflags=0x1, c_cflags=0xbf, c_lflags=0x8a31, c_line=0, c_cc[VMIN]=1, c_cc[VTIME]=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = 0
rt_sigaction(SIGTSTP, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGTSTP, {0x2a95e35f30, [], SA_RESTORER|SA_RESTART, 0x2a9577b5b0}, NULL, 8) = 0
rt_sigaction(SIGINT, NULL, {SIG_IGN}, 8) = 0
rt_sigaction(SIGTERM, NULL, {SIG_IGN}, 8) = 0
rt_sigaction(SIGWINCH, NULL, {SIG_DFL}, 8) = 0
rt_sigaction(SIGWINCH, {0x2a95e361d0, [], SA_RESTORER, 0x2a9577b5b0}, NULL, 8) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {c_iflags=0x2406, c_oflags=0x1, c_cflags=0xbf, c_lflags=0x8a31, c_line=0, c_cc[VMIN]=1, c_cc[VTIME]=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = 0
ioctl(1, SNDCTL_TMR_STOP or TCSETSW, {c_iflags=0x2406, c_oflags=0x1, c_cflags=0xbf, c_lflags=0x8a31, c_line=0, c_cc[VMIN]=1, c_cc[VTIME]=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = 0
write(1, "\33(B\33)0\33[1;69r\33[m\17\33[?7h\33[?1h\33=", 29) = 29
rt_sigaction(SIGTSTP, {SIG_IGN}, {0x2a95e35f30, [], SA_RESTORER|SA_RESTART, 0x2a9577b5b0}, 8) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {c_iflags=0x2406, c_oflags=0x1, c_cflags=0xbf, c_lflags=0x8a31, c_line=0, c_cc[VMIN]=1, c_cc[VTIME]=0, c_cc="\x03\x1c\x7f\x15\x04\x00\x01\x00\x11\x13\x1a\x00\x12\x0f\x17\x16\x00\x00\x00"}) = 0
ioctl(1, TIOCGWINSZ, {ws_row=69, ws_col=153, ws_xpixel=0, ws_ypixel=0}) = 0
write(1, "\33[H\33[J\33[0m\16lqqqqqqqqqqqqqqqqqqqq"..., 754) = 754
rt_sigaction(SIGTSTP, {0x2a95e35f30, [], SA_RESTORER|SA_RESTART, 0x2a9577b5b0}, NULL, 8) = 0
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ KILLED BY sigsegv +++

As you can see near the top you can catch the tail end of locale data loading fine. Any ideas would be nice.

=( I'm stumped.

This may sound trivial, but the version of python is explicitly meant for the platform you are running on, correct?

What OS?

What version of python?

It's a redhat derivative running python 2.3.

Basically the environment I am executing in now is a stripped down version of my dev environment. And it's using the same libraries and binaries... just less of them.

window.addstr() seems to be the culprit, and I'm almost certain it's an environment issue... but I have no clue what it could be if it's not locale.

  1. Symbol version mismatch? Section 16 of the general python library covers curses. Is the
    library version identical with development? what does nm say?

  2. Please show the output of

locale

then we need to see the charsets:

locale -m

I don't get why 764 characters to a textbox that is 153 chars wide?
TIOCGWINSZ succeeds as far as I can see. The qqqq part is a usually a border. addstr is barfing probably because you already blew the stack with ~754 (qqqqq's + the ANSI escapes). Let's focus on charsets first.

You could start by setting locale to POSIX (C) to rule out problems.

I set LANG to C several times in shell. No avail.

Libraries and binaries are identical down to md5sums.

output of locale.

LANG=en_US.utf8
LC_CTYPE="en_US.utf8"
LC_NUMERIC="en_US.utf8"
LC_TIME="en_US.utf8"
LC_COLLATE="en_US.utf8"
LC_MONETARY="en_US.utf8"
LC_MESSAGES="en_US.utf8"
LC_PAPER="en_US.utf8"
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT="en_US.utf8"
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=

It looks like I have no charmaps whatsoever...

Confirming that now... could be the issue.

As for curses... it's using python curses so I am fairly abstracted from a lot of what is going on. Having a hard time getting useful info out of it.

---------- Post updated at 11:57 AM ---------- Previous update was at 11:31 AM ----------

Added and loaded charmap.

No success.

---------- Post updated at 12:13 PM ---------- Previous update was at 11:57 AM ----------

Tested removing box draw and hline draw in code to see if it was a stack fill. No dice, still segfaulting.