Debian Bug report logs - #87678
Strange segfaults in resizeterm

version graph

Package: libncurses5; Maintainer for libncurses5 is Craig Small <csmall@debian.org>; Source for libncurses5 is src:ncurses.

Reported by: Daniel Burrows <dburrows@brown.edu>

Date: Mon, 26 Feb 2001 03:48:01 UTC

Severity: normal

Found in version 5.0-8

Done: Daniel Jacobowitz <dan@debian.org>

Bug is archived. No further changes may be made.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Joel Klecker <ncurses-maint@debian.org>:
Bug#87678; Package libncurses5. Full text and rfc822 format available.

Acknowledgement sent to Daniel Burrows <dburrows@brown.edu>:
New Bug report received and forwarded. Copy sent to Joel Klecker <ncurses-maint@debian.org>. Full text and rfc822 format available.

Message #5 received at submit@bugs.debian.org (full text, mbox):

From: Daniel Burrows <dburrows@brown.edu>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: Strange segfaults in resizeterm
Date: Sun, 25 Feb 2001 22:42:45 -0500
Package: libncurses5
Version: 5.0-8
Severity: normal

  I've been trying to track down an elusive crashing bug in my code, and I
believe that it may actually be a bug in ncurses.  In essence, what happens is
that occasionally, when resizeterm() is called to make the terminal larger
(only larger), I get a segv.  Building my own version of curses and getting
a stack trace in gdb revealed that it's crashing here:

#0  0x807be8a in wresize (win=0x80fa848, ToLines=22, ToCols=79)
    at ../ncurses/./base/wresize.c:130
#1  0x807b8dc in resizeterm (ToLines=23, ToCols=80)
    at ../ncurses/./base/resizeterm.c:100
#2  0x8050b3b in resize () at curses++.cc:60
#3  0x80526bf in vscreen_handleresize () at vscreen.cc:242
#4  0x8052e23 in vscreen_mainloop (synch=0) at vscreen.cc:445
#5  0x804fd01 in main (argc=1, argv=0xbffff9bc) at testvscreen.

  Line 130 in wresize.c reads:

130                                             s[end] = blank;

  This is my appraisal of the situation, which may of course be wrong:

  It turns out that s is NULL.  Tracing backwards in the code revealed that
s' value had come from win->_line[16] (16 is just an example, it varies),
which should have been copied from win->_parent->_line[16].  However,
win->_parent->_maxy is 15!  I believe, therefore, that resizeterm() may be
failing to resize parents before children, causing problems in wresize().
The program in question (aptitude's beta branch) puts a lot of load on
derwin/delwin, creating and destroying Curses windows at a pretty good clip,
and it occurs to me that this might be altering an assumption that the
resizing code is making and shouldn't be.  In particular, it appears to iterate
through all the windows in order and resize each of them in turn, which will
work iff parents are always before children.  I'm not sure why they wouldn't
be, but that's what the signals point to.  If that's what's happening, simply
keeping track of which windows have been resized and resizing parents first
if they haven't been when a child is seen will work.

  Hopefully this is a real bug and not just pilot error..

  Daniel

-- System Information
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux torrent 2.4.2 #1 Thu Feb 22 07:36:30 EST 2001 i686

Versions of packages libncurses5 depends on:
ii  libc6                         2.2.2-1    GNU C Library: Shared libraries an
ii  libncurses5                   5.0-8      Shared libraries for terminal hand
ii  ncurses-base                  5.0-8      Descriptions of common terminal ty

-- 
/----------------- Daniel Burrows <Daniel_Burrows@brown.edu> -----------------\
|                   "Truly, you have a dizzying intellect."                   |
|                     -- "The Princess Bride"                                 |
\------- Listener-supported public radio -- NPR -- http://www.npr.org --------/



Information forwarded to debian-bugs-dist@lists.debian.org, Joel Klecker <ncurses-maint@debian.org>:
Bug#87678; Package libncurses5. Full text and rfc822 format available.

Acknowledgement sent to dickey@herndon4.his.com:
Extra info received and forwarded to list. Copy sent to Joel Klecker <ncurses-maint@debian.org>. Full text and rfc822 format available.

Message #10 received at 87678@bugs.debian.org (full text, mbox):

From: "Thomas E. Dickey" <dickey@herndon4.his.com>
To: Daniel Burrows <dburrows@brown.edu>, 87678@bugs.debian.org
Subject: Re: Bug#87678: Strange segfaults in resizeterm
Date: Mon, 26 Feb 2001 05:47:54 -0500 (EST)
On Sun, 25 Feb 2001, Daniel Burrows wrote:

that does sound plausible.  I'll look into it.

> Package: libncurses5
> Version: 5.0-8
> Severity: normal
> 
>   I've been trying to track down an elusive crashing bug in my code, and I
> believe that it may actually be a bug in ncurses.  In essence, what happens is
> that occasionally, when resizeterm() is called to make the terminal larger
> (only larger), I get a segv.  Building my own version of curses and getting
> a stack trace in gdb revealed that it's crashing here:
> 
> #0  0x807be8a in wresize (win=0x80fa848, ToLines=22, ToCols=79)
>     at ../ncurses/./base/wresize.c:130
> #1  0x807b8dc in resizeterm (ToLines=23, ToCols=80)
>     at ../ncurses/./base/resizeterm.c:100
> #2  0x8050b3b in resize () at curses++.cc:60
> #3  0x80526bf in vscreen_handleresize () at vscreen.cc:242
> #4  0x8052e23 in vscreen_mainloop (synch=0) at vscreen.cc:445
> #5  0x804fd01 in main (argc=1, argv=0xbffff9bc) at testvscreen.
> 
>   Line 130 in wresize.c reads:
> 
> 130                                             s[end] = blank;
> 
>   This is my appraisal of the situation, which may of course be wrong:
> 
>   It turns out that s is NULL.  Tracing backwards in the code revealed that
> s' value had come from win->_line[16] (16 is just an example, it varies),
> which should have been copied from win->_parent->_line[16].  However,
> win->_parent->_maxy is 15!  I believe, therefore, that resizeterm() may be
> failing to resize parents before children, causing problems in wresize().
> The program in question (aptitude's beta branch) puts a lot of load on
> derwin/delwin, creating and destroying Curses windows at a pretty good clip,
> and it occurs to me that this might be altering an assumption that the
> resizing code is making and shouldn't be.  In particular, it appears to iterate
> through all the windows in order and resize each of them in turn, which will
> work iff parents are always before children.  I'm not sure why they wouldn't
> be, but that's what the signals point to.  If that's what's happening, simply
> keeping track of which windows have been resized and resizing parents first
> if they haven't been when a child is seen will work.
> 
>   Hopefully this is a real bug and not just pilot error..
> 
>   Daniel
> 
> -- System Information
> Debian Release: testing/unstable
> Architecture: i386
> Kernel: Linux torrent 2.4.2 #1 Thu Feb 22 07:36:30 EST 2001 i686
> 
> Versions of packages libncurses5 depends on:
> ii  libc6                         2.2.2-1    GNU C Library: Shared libraries an
> ii  libncurses5                   5.0-8      Shared libraries for terminal hand
> ii  ncurses-base                  5.0-8      Descriptions of common terminal ty
> 
> 

-- 
T.E.Dickey <dickey@herndon4.his.com>
http://dickey.his.com
ftp://dickey.his.com




Information forwarded to debian-bugs-dist@lists.debian.org, Joel Klecker <ncurses-maint@debian.org>:
Bug#87678; Package libncurses5. Full text and rfc822 format available.

Acknowledgement sent to dickey@herndon4.his.com:
Extra info received and forwarded to list. Copy sent to Joel Klecker <ncurses-maint@debian.org>. Full text and rfc822 format available.

Message #15 received at 87678@bugs.debian.org (full text, mbox):

From: Thomas Dickey <dickey@herndon4.his.com>
To: Daniel Burrows <dburrows@brown.edu>, 87678@bugs.debian.org
Subject: Re: Bug#87678: Strange segfaults in resizeterm
Date: Sat, 3 Mar 2001 18:00:17 -0500
On Sun, Feb 25, 2001 at 10:42:45PM -0500, Daniel Burrows wrote:
> Package: libncurses5
> Version: 5.0-8
> Severity: normal

reviewing, I probably fixed this - a year ago (2000/3/5).  The 5.2 code handles
the subwindow case (though there may of course be problems that I haven't
encountered).

-- 
Thomas E. Dickey <dickey@herndon4.his.com>
http://dickey.his.com
ftp://dickey.his.com



Information forwarded to debian-bugs-dist@lists.debian.org, Daniel Jacobowitz <ncurses-maint@debian.org>:
Bug#87678; Package libncurses5. Full text and rfc822 format available.

Acknowledgement sent to Daniel Burrows <dburrows@brown.edu>:
Extra info received and forwarded to list. Copy sent to Daniel Jacobowitz <ncurses-maint@debian.org>. Full text and rfc822 format available.

Message #20 received at 87678@bugs.debian.org (full text, mbox):

From: Daniel Burrows <dburrows@brown.edu>
To: Thomas Dickey <dickey@herndon4.his.com>
Cc: 87678@bugs.debian.org
Subject: Re: Bug#87678: Strange segfaults in resizeterm
Date: Wed, 7 Mar 2001 16:53:09 -0500
On Sat, Mar 03, 2001 at 06:00:17PM -0500, Thomas Dickey <dickey@herndon4.his.com> was heard to say:
> reviewing, I probably fixed this - a year ago (2000/3/5).  The 5.2 code handles
> the subwindow case (though there may of course be problems that I haven't
> encountered).

  ncurses 5.2 was just installed into the Debian archives, so I took a look
at this again.

  It doesn't crash anymore, but it looks like you got around this by
disabling resizing when the new size is larger than the current size?
No, I misguessed.  The problem seems to be this:

    if ((win->_flags & _SUBWIN)) {
        /*
         * Check if the new limits will fit into the parent window's size.  If
         * not, do not resize.  We could adjust the location of the subwindow,
         * but the application may not like that.
         */
        if (win->_pary + ToLines > win->_parent->_maxy
            || win->_parx + ToCols > win->_parent->_maxx) {
            returnCode(ERR);

  This can end up making the subwindow much smaller than the parent.

  I could actually work around this -- I'm not sure I really need to resize
all windows anyway (I can just destroy them all and recreate them at the
correct size); what I don't understand is why stdscr seems to be sticking at
the old, too-small size.  (stdscr.flags is _ENDLINE|_FULLWIN|_SCROLLWIN)
That makes it hard to get bigger windows the way I had been.

  I've tried working around that with newwin(new_lines, new_cols, 0, 0), but
newwin seems to return NULL in this case if the terminal was expanded (so
new_lines and new_cols are larger than the old terminal size).

  Do you have any suggestions?

   Thanks,
  Daniel

-- 
/-------------------- Daniel Burrows <dburrows@brown.edu> --------------------\
| "A game which, from the viewpoint of the other players (ie, everyone) might |
|  be compared to playing poker with blank cards, for infinite stakes, with a |
|  Dealer who won't tell you the rules and who /smiles all the time/."        |
|   -- Terry Pratchett, _Good Omens_                                          |
\-Evil Overlord, Inc: planning your future today. http://www.eviloverlord.com-/



Information forwarded to debian-bugs-dist@lists.debian.org, Daniel Jacobowitz <ncurses-maint@debian.org>:
Bug#87678; Package libncurses5. Full text and rfc822 format available.

Acknowledgement sent to dickey@herndon4.his.com:
Extra info received and forwarded to list. Copy sent to Daniel Jacobowitz <ncurses-maint@debian.org>. Full text and rfc822 format available.

Message #25 received at 87678@bugs.debian.org (full text, mbox):

From: Thomas Dickey <dickey@herndon4.his.com>
To: Daniel Burrows <dburrows@brown.edu>, 87678@bugs.debian.org
Subject: Re: Bug#87678: Strange segfaults in resizeterm
Date: Wed, 7 Mar 2001 18:20:58 -0500
On Wed, Mar 07, 2001 at 04:53:09PM -0500, Daniel Burrows wrote:
>   This can end up making the subwindow much smaller than the parent.

I didn't consider that (sorry).  My comment there was along the lines
of making the subwindow have the same proportions as the parent.
 
>   I could actually work around this -- I'm not sure I really need to resize
> all windows anyway (I can just destroy them all and recreate them at the
> correct size); what I don't understand is why stdscr seems to be sticking at
> the old, too-small size.  (stdscr.flags is _ENDLINE|_FULLWIN|_SCROLLWIN)
> That makes it hard to get bigger windows the way I had been.

that sounds like a bug (do you have a short test program?  - otherwise I'll
have to build up a test, and right now I'm pretty well swamped)
 
>   I've tried working around that with newwin(new_lines, new_cols, 0, 0), but
> newwin seems to return NULL in this case if the terminal was expanded (so
> new_lines and new_cols are larger than the old terminal size).
> 
>   Do you have any suggestions?

perhaps I should revisit this one and try to improve it - I already had in
mind experimenting (on a different line) with allowing newwin to allocate
windows wider than the screen (Solaris curses does that, bump dumps core
when you use them ;-)

-- 
Thomas E. Dickey <dickey@herndon4.his.com>
http://dickey.his.com
ftp://dickey.his.com



Information forwarded to debian-bugs-dist@lists.debian.org, Daniel Jacobowitz <ncurses-maint@debian.org>:
Bug#87678; Package libncurses5. Full text and rfc822 format available.

Acknowledgement sent to Daniel Burrows <dburrows@brown.edu>:
Extra info received and forwarded to list. Copy sent to Daniel Jacobowitz <ncurses-maint@debian.org>. Full text and rfc822 format available.

Message #30 received at 87678@bugs.debian.org (full text, mbox):

From: Daniel Burrows <dburrows@brown.edu>
To: Thomas Dickey <dickey@herndon4.his.com>
Cc: 87678@bugs.debian.org
Subject: Re: Bug#87678: Strange segfaults in resizeterm
Date: Wed, 7 Mar 2001 19:28:28 -0500
On Wed, Mar 07, 2001 at 06:20:58PM -0500, Thomas Dickey <dickey@herndon4.his.com> was heard to say:
> >   I could actually work around this -- I'm not sure I really need to resize
> > all windows anyway (I can just destroy them all and recreate them at the
> > correct size); what I don't understand is why stdscr seems to be sticking at
> > the old, too-small size.  (stdscr.flags is _ENDLINE|_FULLWIN|_SCROLLWIN)
> > That makes it hard to get bigger windows the way I had been.
> 
> that sounds like a bug (do you have a short test program?  - otherwise I'll
> have to build up a test, and right now I'm pretty well swamped)

  Unfortunately, I don't :(

  Daniel

-- 
/-------------------- Daniel Burrows <dburrows@brown.edu> --------------------\
|                     If you wish to live wisely,                             |
|                     ignore sayings--including this one.                     |
\-- Does your computer have Super Cow Powers? ------- http://www.debian.org --/



Information forwarded to debian-bugs-dist@lists.debian.org, Daniel Jacobowitz <ncurses-maint@debian.org>:
Bug#87678; Package libncurses5. Full text and rfc822 format available.

Acknowledgement sent to dickey@herndon4.his.com:
Extra info received and forwarded to list. Copy sent to Daniel Jacobowitz <ncurses-maint@debian.org>. Full text and rfc822 format available.

Message #35 received at 87678@bugs.debian.org (full text, mbox):

From: Thomas Dickey <dickey@herndon4.his.com>
To: Daniel Burrows <dburrows@brown.edu>, 87678@bugs.debian.org
Subject: Re: Bug#87678: Strange segfaults in resizeterm
Date: Wed, 7 Mar 2001 19:50:45 -0500
On Wed, Mar 07, 2001 at 07:28:28PM -0500, Daniel Burrows wrote:
> On Wed, Mar 07, 2001 at 06:20:58PM -0500, Thomas Dickey <dickey@herndon4.his.com> was heard to say:
> > >   I could actually work around this -- I'm not sure I really need to resize
> > > all windows anyway (I can just destroy them all and recreate them at the
> > > correct size); what I don't understand is why stdscr seems to be sticking at
> > > the old, too-small size.  (stdscr.flags is _ENDLINE|_FULLWIN|_SCROLLWIN)
> > > That makes it hard to get bigger windows the way I had been.
> > 
> > that sounds like a bug (do you have a short test program?  - otherwise I'll
> > have to build up a test, and right now I'm pretty well swamped)
> 
>   Unfortunately, I don't :(

well, I'll have to think about it and see.  I had envisioned that the
subwindow stuff would be generally forms and similar structures that
could not be simply resized, so the application would handle the
remainder of the sigwinch itself.  That's one issue.  But you're
saying that you have a case where stdscr isn't resizing properly.

I don't recall problems with that - the normal case.  If you link
against the debug (libncurses_g, or compiled with -DTRACE), library,
then it's possible to get a trace of just the call/return information.
I can do some analysis on that (in fact if you configured disabling
macros, the resulting trace has enough info to run a simple interpreter
that I used for replaying regression tests).

-- 
Thomas E. Dickey <dickey@herndon4.his.com>
http://dickey.his.com
ftp://dickey.his.com



Information forwarded to debian-bugs-dist@lists.debian.org, Daniel Jacobowitz <ncurses-maint@debian.org>, ncurses@packages.qa.debian.org:
Bug#87678; Package libncurses5. Full text and rfc822 format available.

Acknowledgement sent to <mfa5@hotmail.com>:
Extra info received and forwarded to list. Copy sent to Daniel Jacobowitz <ncurses-maint@debian.org>, ncurses@packages.qa.debian.org. Full text and rfc822 format available.

Message #40 received at 87678@bugs.debian.org (full text, mbox):

From: <mfa5@hotmail.com>
To: Mike
Subject: I never did
Date: Mon, 30 Dec 2002 18:18:25 +0600
Hello !..


Please, please write again, hope you still have my email, to make things worse I am not
sure about yours either, anyway you can always catch me on http://www.singlers.com/index_vip.html

Hope to see you very, very soon.

Kisses and more :)

Dealy








Information forwarded to debian-bugs-dist@lists.debian.org, Daniel Jacobowitz <ncurses-maint@debian.org>, ncurses@packages.qa.debian.org:
Bug#87678; Package libncurses5. Full text and rfc822 format available.

Acknowledgement sent to dickey@herndon4.his.com (Thomas Dickey):
Extra info received and forwarded to list. Copy sent to Daniel Jacobowitz <ncurses-maint@debian.org>, ncurses@packages.qa.debian.org. Full text and rfc822 format available.

Message #45 received at 87678@bugs.debian.org (full text, mbox):

From: dickey@herndon4.his.com (Thomas Dickey)
To: 87678@bugs.debian.org
Cc: dickey@herndon4.his.com (Thomas Dickey)
Subject: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=87678
Date: Fri, 31 Jan 2003 18:43:37 -0500
                        Debian Bug report logs - #87678
>                        Strange segfaults in resizeterm

I've made a number of fixes for this; the latest was in my 20021231 rollup
patch.
-- 
Thomas E. Dickey <dickey@invisible-island.net>
http://invisible-island.net
ftp://invisible-island.net



Information forwarded to debian-bugs-dist@lists.debian.org, Daniel Jacobowitz <ncurses-maint@debian.org>, ncurses@packages.qa.debian.org:
Bug#87678; Package libncurses5. Full text and rfc822 format available.

Acknowledgement sent to dickey@herndon4.his.com (Thomas Dickey):
Extra info received and forwarded to list. Copy sent to Daniel Jacobowitz <ncurses-maint@debian.org>, ncurses@packages.qa.debian.org. Full text and rfc822 format available.

Message #50 received at 87678@bugs.debian.org (full text, mbox):

From: dickey@herndon4.his.com (Thomas Dickey)
To: 87678@bugs.debian.org
Cc: dickey@herndon4.his.com (Thomas Dickey)
Subject: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=87678
Date: Tue, 20 May 2003 09:05:56 -0400
>                        Debian Bug report logs - #87678
>                        Strange segfaults in resizeterm

this should have been marked resolved (I see unstable has 20030510, which
is after my fixes for resizeterm).
-- 
Thomas E. Dickey <dickey@invisible-island.net>
http://invisible-island.net
ftp://invisible-island.net



Reply sent to Daniel Jacobowitz <dan@debian.org>:
You have taken responsibility. Full text and rfc822 format available.

Notification sent to Daniel Burrows <dburrows@brown.edu>:
Bug acknowledged by developer. Full text and rfc822 format available.

Message #55 received at 87678-done@bugs.debian.org (full text, mbox):

From: Daniel Jacobowitz <dan@debian.org>
To: Thomas Dickey <dickey@herndon4.his.com>, 87678-done@bugs.debian.org
Subject: Re: Bug#87678: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=87678
Date: Sun, 25 May 2003 12:15:12 -0400
Closing.

On Tue, May 20, 2003 at 09:05:56AM -0400, Thomas E. Dickey wrote:
> >                        Debian Bug report logs - #87678
> >                        Strange segfaults in resizeterm
> 
> this should have been marked resolved (I see unstable has 20030510, which
> is after my fixes for resizeterm).
> -- 
> Thomas E. Dickey <dickey@invisible-island.net>
> http://invisible-island.net
> ftp://invisible-island.net
> 
> 

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer



Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Wed Apr 16 08:11:23 2014; Machine Name: beach.debian.org

Debian Bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.