delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/02/18/12:48:08

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <3A900AEF.6155276@ece.gatech.edu>
Date: Sun, 18 Feb 2001 12:48:31 -0500
From: "Charles S. Wilson" <cwilson AT ece DOT gatech DOT edu>
X-Mailer: Mozilla 4.75 [en] (WinNT; U)
X-Accept-Language: en
MIME-Version: 1.0
To: Steven Pemberton <Steven DOT Pemberton AT cwi DOT nl>
CC: cygwin AT cygwin DOT com
Subject: Re: tgetent corrupts stack (cured); Small tgetent program crashes gdb
References: <000a01c099a4$3336f5a0$0100a8c0 AT mxstream DOT nl>

Are you sure that you are actually linking with ncurses?  I just looked
at the code for tgetent (<TOP>/ncurses/tinfo/lib_termcap.src) and it
does, in fact, completely ignore the first argument (*buf).  Is it
possible you are *actually* linking to libtermcap.a ?

I compiled your program:

gcc -o foo.exe foo.c -lcurses
  which links to the cygncurses5.dll library (via libncurses.dll.a)

AND

gcc -o foo.exe foo.c -ltermcap
  which links the the libtermcap.a library which has NOTHING to do with
the ncurses package

and in both cases, the program ran successfully without crashing (I'm
rather surprised that it worked in the second case, but it did.)  I'm
not sure how you are detected "the stack gets corrupted".  Where did
your information concerning buf "must be at least 1038 bytes long" come
from???

--Chuck
ncurses maintainer for cygwin

Steven Pemberton wrote:
> 
> I had a program where tgetent was corrupting the stack. While trying to
> track down the problem, I managed to crash gdb.
> 
> This is a report of two problems.
> 
> 1) 'info tgetent' says that 'the [termcap] emulation ignores the buffer
> pointer bp' (the first param of tgetent). However, this isn't true: the
> buffer really does get used, and it has to be at least 1038 bytes long (the
> 'traditional' size for the tgetent buffer is 1024 bytes), otherwise the
> stack gets corrupted.
> 
> 2) with this tiny program, if I debug it with gdb, and stop before the last
> line (i=t) and try to look at the contents of 'buf', gdb crashes. With a
> value of 1024, or 1536 for the buffer size, gdb doesn't seem to crash.
> 
> #include <stdlib.h>
> #include <curses.h>
> 
> main() {
>   char *s; int t, i;
>   char buf[2048];
>   s= getenv("TERM");
>   t= tgetent(buf, s);
>   i=t;
> }

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019