python curses , segmentation fault on screen.addstr()


 
Thread Tools Search this Thread
Top Forums Programming python curses , segmentation fault on screen.addstr()
# 1  
Old 10-09-2009
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...

Code:
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.
# 2  
Old 10-13-2009
=( I'm stumped.
# 3  
Old 10-13-2009
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?
# 4  
Old 10-13-2009
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.
# 5  
Old 10-13-2009
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
Code:
locale

then we need to see the charsets:

Code:
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.
# 6  
Old 10-13-2009
I set LANG to C several times in shell. No avail.

Libraries and binaries are identical down to md5sums.

output of locale.

Code:
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

C. To segmentation fault or not to segmentation fault, that is the question.

Oddities with gcc, 2.95.3 for the AMIGA and 4.2.1 for MY current OSX 10.14.1... I am creating a basic calculator for the AMIGA ADE *NIX emulator in C as it does not have one. Below are two very condensed snippets of which I have added the results inside the each code section. IMPORTANT!... (11 Replies)
Discussion started by: wisecracker
11 Replies

2. Programming

Using gdb, ignore beginning segmentation fault until reproduce environment segmentation fault

I use a binary name (ie polo) it gets some parameter , so for debugging normally i do this : i wrote script for watchdog my app (polo) and check every second if it's not running then start it , the problem is , if my app , remain in state of segmentation fault for a while (ie 15 ... (6 Replies)
Discussion started by: pooyair
6 Replies

3. UNIX for Dummies Questions & Answers

Segmentation fault

#include<stdio.h> #include<malloc.h> #include<unistd.h> #include<stdlib.h> void *start_1(void *argv) { printf("thread 0x%x\n",(unsigned int)pthread_self()); pthread_exit((void*)1); } void *start_2(void *argv) { printf("thread 0x%x\n",(unsigned int)pthread_self()); return (void*)2; }... (2 Replies)
Discussion started by: vincent__tse
2 Replies

4. UNIX for Advanced & Expert Users

segmentation fault with ps

What does this mean and why is this happening? $ ps -ef | grep ocular Segmentation fault (core dumped) $ ps -ef | grep ocular Segmentation fault (core dumped) $ ps aux | grep ocular Segmentation fault (core dumped) $ ps Segmentation fault (core dumped) $ pkill okular $ ps... (1 Reply)
Discussion started by: cokedude
1 Replies

5. Programming

Segmentation fault in C

i have this code int already_there(char *client_names, char *username) { int i; for(i = 0; i<NUM; i++) { printf("HERE\n"); if (strcmp(client_names, username)==0) return(1); } return(0); } and i get a segmentation fault, whats wrong here? (7 Replies)
Discussion started by: omega666
7 Replies

6. Programming

segmentation fault.

This code is causing a segmentation fault and I can't figure out why. I'm new to UNIX and I need to learn how to avoid this segmentation fault thing. Thank you so much. Thanks also for the great answers to my last post.:):b: int main() { mysqlpp::Connection conn(false); if... (3 Replies)
Discussion started by: sepoto
3 Replies

7. Programming

Clearing screen in Python using curses?

Hi guys, I've got the following code for clearing the screen in my Python shell using curses: import curses scrn = curses.initscr() scrn.clear() However, upon execution, my shell crashes. Would appreciate a pointer in the right direction. Thanks. :D (4 Replies)
Discussion started by: sadistik_exec
4 Replies

8. UNIX for Dummies Questions & Answers

Segmentation Fault

Hi, While comparing primary key data of two tables thr bteq script I am getting this Error. This script is a shell script. *** Error: The following error was encountered on the output file. Script.sh: 3043492 Segmentation fault(coredump) Please let me know how to get through it. ... (5 Replies)
Discussion started by: monika
5 Replies

9. Linux

Segmentation fault

Hi, on a linux Red HAT(with Oracle DB 9.2.0.7) I have following error : RMAN> delete obsolete; RMAN retention policy will be applied to the command RMAN retention policy is set to redundancy 2 using channel ORA_DISK_1 Segmentation fault What does it mean ? And the solution ? Many thanks. (0 Replies)
Discussion started by: big123456
0 Replies

10. AIX

Segmentation fault

I am tring to install Lotus Domino/Notes 5.0.5 on a AIX 4.3.3 server. I go to run the cdrom/ibmpow/install and I get the following error. Lotus Notes for Unix Install Program --------------------------------------------- ./install: 10088 Segmentation fault This had Lotus Notes installed... (1 Reply)
Discussion started by: jshaulis
1 Replies
Login or Register to Ask a Question