emr@hal.UUCP (Edward M. "Harold" Rynes) (10/31/84)
I'm having a problem with curses and I hope someone out there can help me. It would seem that when I create too many windows I get a segmentation fault in wrefresh. However in the program in question I have only created 5 windows when the problem occures. The strange part is that a test program I wrote runs flawlessly on another machine (a 68k based machine) but bombs miserably on our VAX 750. Both are running 4.2 BSD. I have included a copy of the test program below. When I run it I get a sementation fault after "Window #12". #include <curses.h> main(){ int i; WINDOW *win[40], *newwin(); initscr(); mvprintw(0,0,"Starting"); refresh(); for(i=0; i<40; ++i){ win[i] = newwin(0,0,0,0); mvwprintw(win[i],9,9,"Window #%d",i); wrefresh(win[i]); } mvprintw(22,0,"Finished"); refresh(); endwin(); } If anyone has any ideas about what's going on please let me know. Thanx Much, Harold decvax!cwruecmp!hal!emr
acheng@uiucdcs.UUCP (11/05/84)
<</* Written 12:50 am Nov 4, 1984 by emr@hal in uiucdcs:net.unix-wizar */ <</* ---------- "Help! Problems with curses!" ---------- */ << << I'm having a problem with curses and I hope someone out there <<can help me. It would seem that when I create too many windows <<I get a segmentation fault in wrefresh. However in the program <<in question I have only created 5 windows when the problem occures. <<The strange part is that a test program I wrote runs flawlessly on <<another machine (a 68k based machine) but bombs miserably on our <<VAX 750. Both are running 4.2 BSD. I have included a copy of the <<test program below. When I run it I get a sementation fault after <<"Window #12". It ran all okay with our 780 and 750 (both on 4.2BSD). Not a single problem. I suggest you to try some debugger, like adb or dbx, to find where it died. Albert Cheng acheng%uiuc@csnet-relay.ARPA {ihnp4,pur-ee}!uiucdcs!acheng
goldberg@uiucdcs.UUCP (11/06/84)
I believe that these fixes have been installed here at UIUC. You might try them. They are courtesy of Mike Laman. Phil Goldberg goldberg@Uiuc goldberg.Uiuc@csnet ...!{ihnp4,convex,pur-ee}!uiucdcs!goldberg /* Written 11:44 am Nov 18, 1983 by laman@sdcsvax in uiucdcsc:net.bugs */ /* ---------- "Curses bug fixes (4.2 and net.source" ---------- */ Luckily I saved copies of my two bug fixes. Here are the two fixes that I sent out earlier, but which probably didn't make it far out of San Diego. I have since used the second bug fix (the one to wrefresh()) enough to say that it speeds up some of the output up on non CPU bound programs. The speed up was noticeable in some of my programs! First bug report: There is a bug in wdeleteln(). This bug is in the curses library distributed over net.sources, and in the 4.2 BSD distribution (that sdcsvax received at least). Even though the last line of the window gets cleared internally, its "refresh" image may not. The fix is simple. Add the following two lines to the end of the wdeleteln() routine. win->_firstch[win->_maxy-1] = 0; win->_lastch[win->_maxy-1] = win->_maxx - 1; Now wrefresh() will look at the entire line. I have enclosed a little program that will show you if you have the bug. Just compile it with you curses library (termlib too) and run it. #include <curses.h> main() { register i; initscr(); mvaddstr(0, 20, "This program will delete line #5 after"); mvaddstr(1, 20, "writing the line number for each line."); for(i = 0; i < LINES; ++i) mvprintw(i, 0, "Line #%d", i); refresh(); addstr(" You have the bug if the BOTTOM line is not COMPLETELY blank!"); move(5, 0); deleteln(); move(LINES - 3, 0); refresh(); endwin(); } Second Bug Report: The following bug is in the curses library distributed over net.sources, and in the 4.2 BSD distribution (that sdcsvax received at least). The bug is in makech() (in refresh.c). makech() gets called to give output for the given LINE (hint hint). It is interesting that this bug managed to get out. Here is the offending code (the simple fix follows). : : : else if (wx < lch) while (*nsp == *csp) { nsp++; if (!curwin) csp++; ++wx; } else : : : I wrote a program that added '*' to (0, 0) on stdscr then a refresh(). wx ended up with a value of over 3000! That loop walked down the line and the next, ... (all the way down the window!). The following code is the fix. Notice that the ++wx looks just perfect. It really makes one think "they" thought of it, but merely forgot to add the test. : : : else if (wx < lch) while (*nsp == *csp && wx <= lch) { nsp++; if (!curwin) csp++; ++wx; } else : : : I apologize to those of you seeing some of this for a THIRD time, but I want these to get into the distribution. Mike Laman UUCP: {ucbvax,philabs,sdccsu3,sdcsla}!sdcsvax!laman /* End of text from uiucdcsc:net.bugs */
goldberg@uiucdcs.UUCP (11/06/84)
I believe that these fixes have been installed here at UIUC. You might try them. They are courtesy of Mike Laman. Phil Goldberg goldberg@Uiuc goldberg.Uiuc@csnet ...!{ihnp4,convex,pur-ee}!uiucdcs!goldberg /* Written 11:44 am Nov 18, 1983 by laman@sdcsvax in uiucdcsc:net.bugs */ /* ---------- "Curses bug fixes (4.2 and net.source" ---------- */ Luckily I saved copies of my two bug fixes. Here are the two fixes that I sent out earlier, but which probably didn't make it far out of San Diego. I have since used the second bug fix (the one to wrefresh()) enough to say that it speeds up some of the output up on non CPU bound programs. The speed up was noticeable in some of my programs! First bug report: There is a bug in wdeleteln(). This bug is in the curses library distributed over net.sources, and in the 4.2 BSD distribution (that sdcsvax received at least). Even though the last line of the window gets cleared internally, its "refresh" image may not. The fix is simple. Add the following two lines to the end of the wdeleteln() routine. win->_firstch[win->_maxy-1] = 0; win->_lastch[win->_maxy-1] = win->_maxx - 1; Now wrefresh() will look at the entire line. I have enclosed a little program that will show you if you have the bug. Just compile it with you curses library (termlib too) and run it. #include <curses.h> main() { register i; initscr(); mvaddstr(0, 20, "This program will delete line #5 after"); mvaddstr(1, 20, "writing the line number for each line."); for(i = 0; i < LINES; ++i) mvprintw(i, 0, "Line #%d", i); refresh(); addstr(" You have the bug if the BOTTOM line is not COMPLETELY blank!"); move(5, 0); deleteln(); move(LINES - 3, 0); refresh(); endwin(); } Second Bug Report: The following bug is in the curses library distributed over net.sources, and in the 4.2 BSD distribution (that sdcwvax received at least). The bug is in makech() (in refresh.c). makech() gets called to give output for the given LINE (hint hint). It is interesting that this bug managed to get out. Here is the offending code (the simple fix follows). : : : else if (wx < lch) while (*nsp == *csp) { nsp++; if (!curwin) csp++; ++wx; } else : : : I wrote a program that added '*' to (0, 0) on stdscr then a refresh(). wx ended up with a value of over 3000! That loop walked down the line and the next, ... (all the way down the window!). The following code is the fix. Notice that the ++wx looks just perfect. It really makes one think "they" thought of it, but merely forgot to add the test. : : : else if (wx < lch) while (*nsp == *csp && wx <= lch) { nsp++; if (!curwin) csp++; ++wx; } else : : : I apologize to those of you seeing some of this for a THIRD time, but I want these to get into the distribution. Mike Laman UUCP: {ucbvax,philabs,sdccsu3,sdcsla}!sdcsvax!laman /* End of text from uiucdcsc:net.bugs */