Subject: lib/10705: libcurses keypad() segfaulting when reading from stdin
To: None <gnats-bugs@gnats.netbsd.org>
From: Johnny C. Lam <lamj@stat.cmu.edu>
List: netbsd-bugs
Date: 07/28/2000 13:45:14
>Number:         10705
>Category:       lib
>Synopsis:       libcurses keypad() segfaulting when reading from stdin
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 28 13:46:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Johnny C. Lam
>Release:        NetBSD-20000723/i386
>Organization:
	Department of Statistics, Carnegie Mellon University
>Environment:
System: NetBSD mariposa.home.net 1.5C NetBSD 1.5C (MARIPOSA) #0: Mon Jul 24 19:27:52 EDT 2000 jlam@mariposa.home.net:/usr/src/sys/arch/i386/compile/MARIPOSA i386


>Description:
	keypad segfaults when the enclosing program reads from stdin.
It's possible I'm not understanding curses, having never programmed with
it before.  But the following doesn't segfault when I compile it with
ncurses.

#include <curses.h>

int
main ()
{
	initscr ();
	keypad (stdscr, TRUE);
	exit (0);
}

When the above program is compiled and invoked as:

	./foo

everything is alright.  When invoked as:

	echo xxx | ./foo

I get a Memory fault (core dumped).  gdb yields:

GNU gdb 4.17
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386--netbsd"...
Core was generated by `foo'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/libexec/ld.elf_so...done.
Reading symbols from /usr/lib/libcurses.so.3...done.
Reading symbols from /usr/lib/libtermcap.so.0...done.
Reading symbols from /usr/lib/libc.so.12...done.
#0  0x48069ca5 in keypad ()
(gdb) bt
#0  0x48069ca5 in keypad ()
#1  0x8048889 in main () at foo.c:7
#2  0x804862d in ___start ()
(gdb) quit

>How-To-Repeat:
	Try the above.
>Fix:
	Unknown
>Release-Note:
>Audit-Trail:
>Unformatted: