From owner-freebsd-stable@FreeBSD.ORG Tue Nov 8 05:46:33 2005 Return-Path: X-Original-To: freebsd-stable@freebsd.org Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7F07316A41F for ; Tue, 8 Nov 2005 05:46:33 +0000 (GMT) (envelope-from yoshint@flab.fujitsu.co.jp) Received: from fgwmail5.fujitsu.co.jp (fgwmail5.fujitsu.co.jp [192.51.44.35]) by mx1.FreeBSD.org (Postfix) with ESMTP id B71A443D45 for ; Tue, 8 Nov 2005 05:46:32 +0000 (GMT) (envelope-from yoshint@flab.fujitsu.co.jp) Received: from m7.gw.fujitsu.co.jp ([10.0.50.77]) by fgwmail5.fujitsu.co.jp (Fujitsu Gateway) id jA85kVHQ030975 for ; Tue, 8 Nov 2005 14:46:31 +0900 (envelope-from yoshint@flab.fujitsu.co.jp) Received: from s0.gw.fujitsu.co.jp by m7.gw.fujitsu.co.jp (8.12.10/Fujitsu Domain Master) id jA85kU4v031869 for ; Tue, 8 Nov 2005 14:46:30 +0900 (envelope-from yoshint@flab.fujitsu.co.jp) Received: from s0.gw.fujitsu.co.jp (s0 [127.0.0.1]) by s0.gw.fujitsu.co.jp (Postfix) with ESMTP id 78E0F32C17C for ; Tue, 8 Nov 2005 14:46:29 +0900 (JST) Received: from dm.kawasaki.flab.fujitsu.co.jp (dm.kawasaki.flab.fujitsu.co.jp [10.25.192.1]) by s0.gw.fujitsu.co.jp (Postfix) with ESMTP id E459732C15A for ; Tue, 8 Nov 2005 14:46:28 +0900 (JST) Received: from dm.kawasaki.flab.fujitsu.co.jp by dm.kawasaki.flab.fujitsu.co.jp (8.9.3p2/3.7W-051028-Fujitsu Labs. Kawasaki Domain Mail Master (NAVGW)) id OAA18080; Tue, 8 Nov 2005 14:46:28 +0900 (JST) Received: from palomino.cad.flab.fujitsu.co.jp ([10.25.155.139]) by dm.kawasaki.flab.fujitsu.co.jp (NAVGW 2.5.2.9) with SMTP id M2005110814462803425 for ; Tue, 08 Nov 2005 14:46:28 +0900 Received: from palomino.cad.flab.fujitsu.co.jp (localhost [IPv6:::1]) by palomino.cad.flab.fujitsu.co.jp (8.13.3/8.13.1) with ESMTP id jA85kS4T035397 for ; Tue, 8 Nov 2005 14:46:28 +0900 (JST) (envelope-from yoshint@flab.fujitsu.co.jp) From: TOMITA Yoshinori To: freebsd-stable@freebsd.org MIME-Version: 1.0 (generated by WEMIKO 1.14.1 - =?ISO-2022-JP?B?Ig==?= =?ISO-2022-JP?B?GyRCNl9KXExTQ24bKEIi?=) Content-Type: text/plain; charset=US-ASCII Date: Tue, 08 Nov 2005 14:46:28 +0900 Message-ID: User-Agent: T-gnus/6.17.4 (based on No Gnus v0.4) WEMIKO/1.14.1 (=?ISO-2022-JP?B?GyRCNl9KXExTQ24bKEI=?=) SLIM/1.14.7 (=?ISO-2022-JP?B?GyRCPHIwZjpMTD4bKEI=?=) APEL/10.3 XEmacs/21.4.17 (i386-unknown-freebsd5.4) MULE Mule-UCS/0.84 (=?ISO-2022-JP?B?S09VR0VU?= =?ISO-2022-JP?B?U1VEQUk6GyRCOH43bkJmGyhC?=) Subject: FreeBSD6 /bin/tcsh ls-F : Floating exception (core dumped) X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Nov 2005 05:46:33 -0000 tcsh 6.14.00 of FreeBSD 6-STABLE will crash by ls-F built-in command. % /bin/tcsh % cd /SOMEWHERE % ls-F Floating exception (core dumped) If login shell is /bin/tcsh, this results in unintentional logout. This problem occurs for example, 1. charset of filename is ja_JP.eucJP 2. LANG is not ja_JP.eucJP 3. run ls-F This is not only the case. GDB stack trace: ----------------------------------------------------- (gdb) where #0 0x0806e947 in print_by_column (dir=0x80b9b94, items=0x8167c08, count=331, no_file_suffix=1) at /usr/src/bin/csh/../../contrib/tcsh/tw.parse.c:2071 #1 0x0806d993 in tw_list_items (looking=4, numitems=331, list_max=0) at /usr/src/bin/csh/../../contrib/tcsh/tw.parse.c:1394 #2 0x0806e107 in t_search (word=0x80b9b94, wp=0x0, command=LIST, max_word_length=0, looking=4, list_max=80, pat=0x80b9b94, suf=0) at /usr/src/bin/csh/../../contrib/tcsh/tw.parse.c:1706 #3 0x0808119b in dolist (v=0x8135cbc, c=0x81677e8) at /usr/src/bin/csh/../../contrib/tcsh/tc.func.c:251 #4 0x08056a2d in func (t=0x81677e8, bp=0x80909e0) at /usr/src/bin/csh/../../contrib/tcsh/sh.func.c:152 #5 0x08065ab7 in execute (t=0x81677e8, wanttty=50551, pipein=0x0, pipeout=0x0, do_glob=1) at /usr/src/bin/csh/../../contrib/tcsh/sh.sem.c:650 #6 0x08065dd3 in execute (t=0x81652a8, wanttty=50551, pipein=0x0, pipeout=0x0, do_glob=1) at /usr/src/bin/csh/../../contrib/tcsh/sh.sem.c:721 #7 0x0804d081 in process (catch=1) at /usr/src/bin/csh/../../contrib/tcsh/sh.c:2180 #8 0x0804bd8b in main (argc=0, argv=0xbfbfeb74) at /usr/src/bin/csh/../../contrib/tcsh/sh.c:1362 ----------------------------------------------------- signal comes from tw.parse.c: columns = TermH / maxwidth; /* PWP: terminal size change */ ^^^^^^^^^^^ There are cases when maxwidth == 0 !!! maxwidth is computed by ... maxwidth = max(maxwidth, (unsigned int) NLSStringWidth(items[i])); and NLSStringWidth() is defined in tc.nls.c int NLSStringWidth(Char *s) { int w = 0; while (*s) w += wcwidth(*s++); return w; } wcwidth() returns -1 when char is not printable depending LANG. If LANG is not matched with coding set used as filenames, wcwidth() will return -1. So, int NLSStringWidth() might return negative value such as -1 or -2. As a result, the next sentence in tw.parse.c maxwidth += no_file_suffix ? 1 : 2; /* for the file tag and space */ makes maxwidth=0. Here is a tiny patch. ----------------------------------------------------- --- tc.nls.c.org Tue Nov 8 14:13:22 2005 +++ tc.nls.c Tue Nov 8 14:04:54 2005 @@ -89,8 +89,10 @@ NLSStringWidth(Char *s) { int w = 0; - while (*s) - w += wcwidth(*s++); + while (*s) { + int tmp = wcwidth(*s++); + w += (tmp>0) ? tmp : 0; + } return w; } ----------------------------------------------------- -- --- TOMITA Yoshinori (Fujitsu Laboratories Ltd., Kawasaki, Japan)