Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 (MC840302); site chalmers.UUCP Path: utzoo!watmath!clyde!akgua!sdcsvax!dcdwest!ittvax!decvax!mcvax!enea!chalmers!per From: per@chalmers.UUCP Newsgroups: net.bugs.4bsd Subject: Bug in curses package Message-ID: <82@chalmers.UUCP> Date: Thu, 17-May-84 08:07:56 EDT Article-I.D.: chalmers.82 Posted: Thu May 17 08:07:56 1984 Date-Received: Sun, 20-May-84 00:22:50 EDT Organization: Dept. of CS, Chalmers, Sweden Lines: 87 Subject: Curses package sometimes dump core. Index: usr.lib/libcurses 4.2BSD Description: Screen oriented programs that worked on terminals like vt100, caused 'segmentation fault' when run on facit 4440. (Swedish terminal, 72 lines by 80 columns). The problem was caused by a loop like: while (*cp++ == *dp++) ; (Now I start guessing) The reason this hasn't been detected before is that the curses package does a lot of calloc()/free(). The amount of space used by 'curscr' and 'stdscr', allocated by initscr(), is less than what is used during other initialiations. The result is that "above" 'curscr' and 'stdscr' there is memory that no longer is initialized to 0. But this is only true if 'stdscr' and 'curscr' are small enough. That isn't the case when the screen is 72x80. Repeat-By: /* start of test.c */ #include #define FMT "libcurses test, line %d" main(argc, argv) { register i; /* simulate 72x80 screen (facit 4440) */ LINES = 72; COLS = 80; initscr(); for (i = 0; i < 15; i++) mvprintw(i, 5, FMT, i+1); move(20,1); refresh(); endwin(); } /* end of test.c */ compile with: cc test.c -lcurses -ltermcap run by: a.out Fix: Diff listing (edited) follows. Line numbers are not correct due to other minor changes. *** refresh.c.old Wed May 16 23:48:53 1984 --- refresh.c.new Sat May 12 00:17:46 1984 *************** *** 235,243 lx = wx + win->_begx; } else if (wx < lch) ! while (*nsp == *csp) { nsp++; if (!curwin) csp++; ++wx; } --- 240,248 ----- lx = wx + win->_begx; } else if (wx < lch) ! while (*nsp == *csp && wx < lch) { nsp++; if (!curwin) csp++; ++wx; } Per Westerlund Dept of Comp Sci Chalmers U of Tech S-412 96 Gothenburg SWEDEN