Subject: lib/36545: vi core dumps in a screen
To: None <lib-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Bernd Ernesti <pr200706@veego.de>
List: netbsd-bugs
Date: 06/24/2007 09:20:00
>Number:         36545
>Category:       lib
>Synopsis:       vi core dumps in a screen
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jun 24 09:20:00 +0000 2007
>Originator:     Bernd Ernesti
>Release:        NetBSD 4.99.20
>Organization:
	
>Environment:
System: NetBSD 4.99.20
Architecture: i386
Machine: i386
>Description:
	vi core dumps in a screen (pkgsrc/misc/screen) since the nwcurses
	was merged into current.

Program received signal SIGSEGV, Segmentation fault.
0xbbbd8fcc in add_new_key (current=0x104, chr=<value optimized out>, key_type=1, symbol=0)
    at /src/lib/libcurses/getch.c:269
269             if (current->mapping[(unsigned char) chr] < 0) {
(gdb) bt
#0  0xbbbd8fcc in add_new_key (current=0x104, chr=<value optimized out>, key_type=1, symbol=0)
    at /src/lib/libcurses/getch.c:269
#1  0xbbbd9182 in add_key_sequence (screen=<value optimized out>, sequence=0xbfbfdf14 "\033[6~", 
    key_type=338) at /src/lib/libcurses/getch.c:401
#2  0xbbbd9310 in __init_getch (screen=0x809f000) at /src/lib/libcurses/getch.c:463
#3  0xbbbd79ae in __init_get_wch (screen=0x809f000) at /src/lib/libcurses/get_wch.c:68
#4  0xbbbd65e6 in newterm (type=0x808e070 "screen", outfd=0x808a4c8, infd=0x808a470)
    at /src/lib/libcurses/screen.c:178
#5  0x0804c6ff in cl_screen ()
#6  0x080796ff in vi ()
#7  0x080664cc in editor ()
#8  0x0804b72e in main ()

	I tried to build a debugging libcurses with DEBUG_CURSES, but then the
	core dump doesn't happen anymore.
	Setting the environemnt variable DBG to "-O2 -g" produces a
	library which cause the core dump.

	Setting TERM to xterm instead of the default screen if you use screen,
	stopped this core dump.

	This is a diff for two trace files, when I compiled a library with
	DEBUG_CURSES where the core dump doesn't happen:
	- = TERM set to screen trace
	+ = TERM set to xterm trace

-Processing termcap entry kl, sequence 
-add_key_sequence: add key sequence: (KEY_LEFT)
-Adding character ^@ of type 2, symbol 0x104
+Processing termcap entry kl, sequence ^[OD
+add_key_sequence: add key sequence: ESCOD(KEY_LEFT)
+Adding character ^[ of type 1, symbol 0x0
+Keymap already known
+Adding character O of type 1, symbol 0x0
+Keymap already known
+Adding character D of type 2, symbol 0x104
 Adding leaf key

>How-To-Repeat:
	screen
	vi
>Fix: