I'd like to update editors/zile, but ever since it was switched to
curses(3), it crashes on exit:

zile in free(): error: free_pages: pointer to wrong page
Abort trap (core dumped) 

...
#8  0x000000004b8fb103 in del_curterm (termp=0x4330a000)
    at /usr/src/lib/libcurses/tinfo/lib_cur_term.c:67
#9  0x000000004b90a536 in delscreen (sp=0x4a061000)
    at /usr/src/lib/libcurses/base/lib_set_term.c:112
#10 0x0000000000417ae3 in term_close () at term_ncurses.c:122
#11 0x0000000000411810 in main (argc=1, argv=0x7f7ffffc9778) at main.c:330

Apparently, curses tries to free some internal structures that
haven't been properly initialized.  Does anybody spy an error in
the code below (from zile/src/term_ncurses.c)?  Nothing else appears
to touch *screen.

--------------->
typedef SCREEN Screen;
Screen *screen;
int xterm;

...

void term_init(void)
{
  char *term = getenv("TERM");

  if (term && strcmp(term, "xterm") == 0) {
    xterm = TRUE;
    printf("\033[?1036;h");       /* Make Meta send ESC */
  }
  screen = newterm(NULL, stdout, stdin);
  set_term(screen);

  term_set_size((size_t)COLS, (size_t)LINES);

  noecho();
  nonl();
  raw();
  intrflush(stdscr, FALSE);
  keypad(stdscr, TRUE);
}

void term_close(void)
{
  /* Clear last line. */
  term_move((size_t)(LINES - 1), 0);
  term_clrtoeol();
  term_refresh();

  /* Free memory and finish with ncurses. */
  endwin();
  delscreen(screen);
  if (xterm) {
    printf("\033[?1036;l");     /* Reset Meta key */
    printf("\r         \r");    /* Overwrite string in previous line
                                   for terminal emulators that don't
                                   understand it */
  }
  screen = NULL;
}
<---------------

Dropping the extra SCREEN handling, which seems to serve no particular
purpose, and using plain initscr(3) seems to work, but still, what's
wrong?


Index: Makefile
===================================================================
RCS file: /cvs/ports/editors/zile/Makefile,v
retrieving revision 1.9
diff -u -r1.9 Makefile
--- Makefile    25 Jul 2005 15:26:37 -0000      1.9
+++ Makefile    14 Mar 2006 20:35:31 -0000
@@ -2,7 +2,7 @@
 
 COMMENT=               "zile is lossy emacs"
 
-DISTNAME=              zile-2.2.2
+DISTNAME=              zile-2.2.13
 CATEGORIES=            editors
 HOMEPAGE=              http://zile.sourceforge.net/
 
@@ -11,7 +11,7 @@
 PERMIT_PACKAGE_FTP=    Yes
 PERMIT_DISTFILES_CDROM= Yes
 PERMIT_DISTFILES_FTP=  Yes
-WANTLIB=               c termcap
+WANTLIB=               c ncurses
 
 MASTER_SITES=          ${MASTER_SITE_SOURCEFORGE:=zile/}
 
Index: distinfo
===================================================================
RCS file: /cvs/ports/editors/zile/distinfo,v
retrieving revision 1.6
diff -u -r1.6 distinfo
--- distinfo    25 Jul 2005 15:26:37 -0000      1.6
+++ distinfo    14 Mar 2006 20:35:31 -0000
@@ -1,4 +1,4 @@
-MD5 (zile-2.2.2.tar.gz) = 7eb5d67ed3bb58e2f4cf94a841c1d7bb
-RMD160 (zile-2.2.2.tar.gz) = 15c847d1b1f0b04366d24d3e9a4079010dadb47f
-SHA1 (zile-2.2.2.tar.gz) = 69bb595f3a917cf6c363e5b69b90db7e73d41cde
-SIZE (zile-2.2.2.tar.gz) = 333424
+MD5 (zile-2.2.13.tar.gz) = d2156809cf1482c2f670d35b083babb5
+RMD160 (zile-2.2.13.tar.gz) = 01d784d8cab51584ea1155483bf326414f9877ec
+SHA1 (zile-2.2.13.tar.gz) = f8593ea026ed04bd878f2310065dc569d7ea44c6
+SIZE (zile-2.2.13.tar.gz) = 329639
Index: patches/patch-src_term_ncurses_c
===================================================================
RCS file: patches/patch-src_term_ncurses_c
diff -N patches/patch-src_term_ncurses_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_term_ncurses_c    14 Mar 2006 20:35:31 -0000
@@ -0,0 +1,37 @@
+$OpenBSD$
+--- src/term_ncurses.c.orig    Tue Mar 14 20:59:08 2006
++++ src/term_ncurses.c Tue Mar 14 20:59:49 2006
+@@ -35,8 +35,6 @@
+ #include "zile.h"
+ #include "extern.h"
+ 
+-typedef SCREEN Screen;
+-Screen *screen;
+ int xterm;
+ 
+ void term_move(size_t y, size_t x)
+@@ -98,8 +96,7 @@ void term_init(void)
+     xterm = TRUE;
+     printf("\033[?1036;h");       /* Make Meta send ESC */
+   }
+-  screen = newterm(NULL, stdout, stdin);
+-  set_term(screen);
++  initscr();
+ 
+   term_set_size((size_t)COLS, (size_t)LINES);
+ 
+@@ -119,14 +116,12 @@ void term_close(void)
+ 
+   /* Free memory and finish with ncurses. */
+   endwin();
+-  delscreen(screen);
+   if (xterm) {
+     printf("\033[?1036;l");     /* Reset Meta key */
+     printf("\r         \r");    /* Overwrite string in previous line
+                                    for terminal emulators that don't
+                                    understand it */
+   }
+-  screen = NULL;
+ }
+ 
+ static size_t translate_key(int c)
-- 
Christian "naddy" Weisgerber                          [EMAIL PROTECTED]

Reply via email to