From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 18 05:03:48 2011 Received: (at submit) by debbugs.gnu.org; 18 Aug 2011 09:03:49 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QtyVv-0001jo-C0 for submit@debbugs.gnu.org; Thu, 18 Aug 2011 05:03:48 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QtyVq-0001je-KB for submit@debbugs.gnu.org; Thu, 18 Aug 2011 05:03:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QtyTv-0005GU-GV for submit@debbugs.gnu.org; Thu, 18 Aug 2011 05:01:44 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:46965) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QtyTv-0005GF-Ez for submit@debbugs.gnu.org; Thu, 18 Aug 2011 05:01:43 -0400 Received: from eggs.gnu.org ([140.186.70.92]:51151) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QtyTu-0005CU-Ax for bug-gnu-emacs@gnu.org; Thu, 18 Aug 2011 05:01:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QtyTt-00059u-4d for bug-gnu-emacs@gnu.org; Thu, 18 Aug 2011 05:01:42 -0400 Received: from msa102.auone-net.jp ([61.117.18.162]:39596) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QtyTs-00058J-Ns for bug-gnu-emacs@gnu.org; Thu, 18 Aug 2011 05:01:40 -0400 Received: from GUNGNIR.med.osaka-cu.ac.jp (121-87-117-132f1.nar1.eonet.ne.jp [121.87.117.132]) by msa102.auone-net.jp (au one net msa) with ESMTP id DC129360038; Thu, 18 Aug 2011 18:01:29 +0900 (JST) Date: Thu, 18 Aug 2011 18:01:13 +0900 From: Kazuhiro Ito To: bug-gnu-emacs@gnu.org Subject: 23.3.50; The first call of encode-coding-region() returns wrong result on on Windows User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 EasyPG/1.0.0 Emacs/23.3.50 (i386-mingw-nt6.1.7601) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.6 - "Maruoka") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Message-Id: <20110818090129.DC129360038@msa102.auone-net.jp> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -5.3 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.4 (-----) When I start Emacs and evaluate the below code, unexpected result returns. (let ((func (lambda () (with-temp-buffer (mapc 'insert '(166 25339)) (encode-coding-region (point-min) (point-max) 'ctext-unix) (buffer-string))))) (cons (funcall func) (funcall func))) -> ("=C2=A6=E6=8B=BB^@^@^@^@^@^@^@^@^@^@" . "^[$(D\"C^[$(H*f^[(B")=20 car of the result is not constant. In the worst case, emacs crashes. It doesn't occur on Linux. If I evaluate twice, car and cdr of the last result are correct. Using encode-coding-string instead of encode-coding-region has no problem.=20 (let ((func (lambda () (encode-coding-string (mapconcat 'char-to-string '(166 25339) "") 'ctext-unix)))) (cons (funcall func) (funcall func))) -> ("^[$(D\"C^[$(H*f^[(B" . "^[$(D\"C^[$(H*f^[(B") Before calling encode-coding-string also can avoid problem. (let ((func (lambda () (with-temp-buffer (mapc 'insert '(166 25339)) (encode-coding-region (point-min) (point-max) 'ctext-unix) (buffer-string))))) (encode-coding-string (mapconcat 'char-to-string '(166 25339) "") 'ctext-unix) (cons (funcall func) (funcall func))) -> ("^[$(D\"C^[$(H*f^[(B" . "^[$(D\"C^[$(H*f^[(B") --=20 Kazuhiro Ito From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 18 05:50:39 2011 Received: (at 9318) by debbugs.gnu.org; 18 Aug 2011 09:50:39 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QtzFH-0002mZ-6J for submit@debbugs.gnu.org; Thu, 18 Aug 2011 05:50:39 -0400 Received: from mail-out.m-online.net ([212.18.0.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QtzFD-0002mQ-Ib for 9318@debbugs.gnu.org; Thu, 18 Aug 2011 05:50:36 -0400 Received: from frontend1.mail.m-online.net (frontend1.mail.intern.m-online.net [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 3A7B01824474; Thu, 18 Aug 2011 11:48:35 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.8.164]) by mail.m-online.net (Postfix) with ESMTP id 6B1641C00076; Thu, 18 Aug 2011 11:48:35 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.180]) by localhost (dynscan1.mail.m-online.net [192.168.8.164]) (amavisd-new, port 10024) with ESMTP id jDF-n2wxAL4f; Thu, 18 Aug 2011 11:48:34 +0200 (CEST) Received: from hase.home (ppp-88-217-109-224.dynamic.mnet-online.de [88.217.109.224]) by mail.mnet-online.de (Postfix) with ESMTP; Thu, 18 Aug 2011 11:48:34 +0200 (CEST) From: Andreas Schwab To: Kazuhiro Ito Subject: Re: bug#9318: 23.3.50; The first call of encode-coding-region() returns wrong result on on Windows References: <20110818090129.DC129360038@msa102.auone-net.jp> X-Yow: Yow! I'm imagining a surfer van filled with soy sauce! Date: Thu, 18 Aug 2011 11:48:36 +0200 In-Reply-To: <20110818090129.DC129360038@msa102.auone-net.jp> (Kazuhiro Ito's message of "Thu, 18 Aug 2011 18:01:13 +0900") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 9318 Cc: 9318@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) Kazuhiro Ito writes: > Before calling encode-coding-string also can avoid problem. Perhaps something is clobbered by some autoloading? Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 18 17:36:05 2011 Received: (at 9318) by debbugs.gnu.org; 18 Aug 2011 21:36:05 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QuAFx-0002cy-6Z for submit@debbugs.gnu.org; Thu, 18 Aug 2011 17:36:05 -0400 Received: from msa103.auone-net.jp ([61.117.18.163]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QuAFu-0002cZ-G7 for 9318@debbugs.gnu.org; Thu, 18 Aug 2011 17:36:04 -0400 Received: from GUNGNIR.med.osaka-cu.ac.jp (121-87-117-132f1.nar1.eonet.ne.jp [121.87.117.132]) by msa103.auone-net.jp (au one net msa) with ESMTP id 34A0A34803A; Fri, 19 Aug 2011 06:33:58 +0900 (JST) Date: Fri, 19 Aug 2011 06:33:41 +0900 From: Kazuhiro Ito To: Andreas Schwab Subject: Re: bug#9318: 23.3.50; The first call of encode-coding-region() returns wrong result on on Windows In-Reply-To: References: <20110818090129.DC129360038@msa102.auone-net.jp> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 EasyPG/1.0.0 Emacs/23.3.50 (i386-mingw-nt6.1.7601) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Message-Id: <20110818213359.34A0A34803A@msa103.auone-net.jp> X-Spam-Score: -3.7 (---) X-Debbugs-Envelope-To: 9318 Cc: 9318@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.6 (---) > Perhaps something is clobbered by some autoloading? I think I don't understand what you mean excatly, but these phenomena are reproducible on precompiled binary (*1) with -Q option. (*1) http://ftp.gnu.org/pub/gnu/emacs/windows/emacs-23.3-bin-i386.zip -- Kazuhiro Ito From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 19 09:48:48 2011 Received: (at 9318) by debbugs.gnu.org; 19 Aug 2011 13:48:48 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QuPRH-00014f-Qz for submit@debbugs.gnu.org; Fri, 19 Aug 2011 09:48:48 -0400 Received: from msa103.auone-net.jp ([61.117.18.163]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QuPRE-00014W-HW for 9318@debbugs.gnu.org; Fri, 19 Aug 2011 09:48:46 -0400 Received: from GUNGNIR.med.osaka-cu.ac.jp (121-87-117-132f1.nar1.eonet.ne.jp [121.87.117.132]) by msa103.auone-net.jp (au one net msa) with ESMTP id 9727A34803A; Fri, 19 Aug 2011 22:46:36 +0900 (JST) Date: Fri, 19 Aug 2011 22:46:18 +0900 From: Kazuhiro Ito To: 9318@debbugs.gnu.org Subject: 23.3.50; The first call of encode-coding-region() returns wrong result In-Reply-To: <20110818090129.DC129360038@msa102.auone-net.jp> References: <20110818090129.DC129360038@msa102.auone-net.jp> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 EasyPG/1.0.0 Emacs/23.3.50 (i386-mingw-nt6.1.7601) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.6 - "Maruoka") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Message-Id: <20110819134637.9727A34803A@msa103.auone-net.jp> X-Spam-Score: -3.6 (---) X-Debbugs-Envelope-To: 9318 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.5 (---) > When I start Emacs and evaluate the below code, unexpected result returns. > (let ((func (lambda () > (with-temp-buffer > (mapc 'insert '(166 25339)) > (encode-coding-region (point-min) (point-max) 'ctext-unix) > (buffer-string))))) > (cons (funcall func) > (funcall func))) > -> ("=C2=A6=E6=8B=BB^@^@^@^@^@^@^@^@^@^@" . "^[$(D\"C^[$(H*f^[(B")=20 > car of the result is not constant. I noticed this problem is not Windows specific. I confirmed that it is reproducible in Emacs 23.3.1 (build by pkgsrc) on NetBSD/amd64 via SSH from remote host. But it doesn't occur on openSUSE 11.3. --=20 Kazuhiro Ito From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 20 17:28:25 2011 Received: (at 9318) by debbugs.gnu.org; 20 Aug 2011 21:28:25 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qut5c-0007uU-UP for submit@debbugs.gnu.org; Sat, 20 Aug 2011 17:28:25 -0400 Received: from vm-emlprdomr-05.its.yale.edu ([130.132.50.146]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qut5b-0007uM-1v for 9318@debbugs.gnu.org; Sat, 20 Aug 2011 17:28:24 -0400 Received: from furball ([64.134.100.139]) (authenticated bits=0) by vm-emlprdomr-05.its.yale.edu (8.14.4/8.14.4) with ESMTP id p7KLQ50j026902 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Sat, 20 Aug 2011 17:26:05 -0400 From: Chong Yidong To: Kazuhiro Ito Subject: Re: bug#9318: 23.3.50; The first call of encode-coding-region() returns wrong result References: <20110818090129.DC129360038@msa102.auone-net.jp> <20110819134637.9727A34803A@msa103.auone-net.jp> Date: Sat, 20 Aug 2011 17:26:04 -0400 In-Reply-To: <20110819134637.9727A34803A@msa103.auone-net.jp> (Kazuhiro Ito's message of "Fri, 19 Aug 2011 22:46:18 +0900") Message-ID: <877h67vkpf.fsf@stupidchicken.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.71 on 130.132.50.146 X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 9318 Cc: 9318@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) Kazuhiro Ito writes: >> When I start Emacs and evaluate the below code, unexpected result return= s. > >> (let ((func (lambda () >> (with-temp-buffer >> (mapc 'insert '(166 25339)) >> (encode-coding-region (point-min) (point-max) 'ctext-unix) >> (buffer-string))))) >> (cons (funcall func) >> (funcall func))) >> -> ("=C2=A6=E6=8B=BB^@^@^@^@^@^@^@^@^@^@" . "^[$(D\"C^[$(H*f^[(B") > >> car of the result is not constant. > > I noticed this problem is not Windows specific. I confirmed that it > is reproducible in Emacs 23.3.1 (build by pkgsrc) on NetBSD/amd64 via > SSH from remote host. But it doesn't occur on openSUSE 11.3. Could you run Emacs under a debugger, trigger the crash, and provide a backtrace? (You will need to have compiled Emacs with debugging symbols.) From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 20 20:19:48 2011 Received: (at 9318) by debbugs.gnu.org; 21 Aug 2011 00:19:48 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QuvlT-0002vX-PE for submit@debbugs.gnu.org; Sat, 20 Aug 2011 20:19:48 -0400 Received: from msa104.auone-net.jp ([61.117.18.164]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QuvlO-0002vL-OV for 9318@debbugs.gnu.org; Sat, 20 Aug 2011 20:19:46 -0400 Received: from GUNGNIR.med.osaka-cu.ac.jp (unknown [114.179.36.76]) by msa104.auone-net.jp (au one net msa) with ESMTP id D29052C037; Sun, 21 Aug 2011 09:17:26 +0900 (JST) Date: Sun, 21 Aug 2011 09:17:05 +0900 From: Kazuhiro Ito To: Chong Yidong Subject: Re: bug#9318: 23.3.50; The first call of encode-coding-region() returns wrong result In-Reply-To: <877h67vkpf.fsf@stupidchicken.com> References: <20110818090129.DC129360038@msa102.auone-net.jp> <20110819134637.9727A34803A@msa103.auone-net.jp> <877h67vkpf.fsf@stupidchicken.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 EasyPG/1.0.0 Emacs/23.3.50 (i386-mingw-nt6.1.7601) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.6 - "Maruoka") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Message-Id: <20110821001726.D29052C037@msa104.auone-net.jp> X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 9318 Cc: 9318@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) > >> When I start Emacs and evaluate the below code, unexpected result retu= rns. > > > >> (let ((func (lambda () > >> (with-temp-buffer > >> (mapc 'insert '(166 25339)) > >> (encode-coding-region (point-min) (point-max) 'ctext-unix) > >> (buffer-string))))) > >> (cons (funcall func) > >> (funcall func))) > >> -> ("=C2=A6=E6=8B=BB^@^@^@^@^@^@^@^@^@^@" . "^[$(D\"C^[$(H*f^[(B") > > > > I noticed this problem is not Windows specific. I confirmed that it > > is reproducible in Emacs 23.3.1 (build by pkgsrc) on NetBSD/amd64 via > > SSH from remote host. But it doesn't occur on openSUSE 11.3. >=20 > Could you run Emacs under a debugger, trigger the crash, and provide a > backtrace? (You will need to have compiled Emacs with debugging > symbols.) I built Emacs 23.3 with "-O0 -g" option on NetBSD 5.1 (amd64), and started with below commad (via SSH). gdb --args emacs -Q --no-splash Next, inputtedand below code and evaluated with C-x C-e. (progn (goto-char (point-min)) (insert #x80) (insert (make-string 16 ?A)) (encode-coding-region 1 18 'ctext-unix)) backtrace is below. Please let me know if you need more information. Program received signal SIGSEGV, Segmentation fault. 0x0000000000557419 in mark_object (arg=3D4702111234474983745) at alloc.c:54= 73 5473 if (STRING_MARKED_P (ptr)) (gdb) bt full #0 0x0000000000557419 in mark_object (arg=3D4702111234474983745) at alloc.= c:5473 ptr =3D (struct Lisp_String *) 0x4141414141414140 obj =3D 4702111234474983745 cdr_count =3D 0 #1 0x0000000000557320 in mark_char_table (ptr=3D0x1281800) at alloc.c:5405 val =3D 4702111234474983745 size =3D 130 i =3D 0 #2 0x0000000000557315 in mark_char_table (ptr=3D0x17f6c00) at alloc.c:5402 val =3D 19404805 size =3D 34 i =3D 14 #3 0x0000000000557315 in mark_char_table (ptr=3D0x13ea700) at alloc.c:5402 val =3D 25127941 size =3D 18 i =3D 6 #4 0x0000000000557315 in mark_char_table (ptr=3D0x10ba800) at alloc.c:5402 val =3D 20883205 size =3D 68 i =3D 4 #5 0x0000000000557838 in mark_object (arg=3D17541125) at alloc.c:5567 obj =3D 17541125 cdr_count =3D 0 #6 0x0000000000557228 in mark_vectorlike (ptr=3D0xb16480) at alloc.c:5377 size =3D 10 i =3D 9 #7 0x0000000000557855 in mark_object (arg=3D11625605) at alloc.c:5569 obj =3D 11625605 cdr_count =3D 0 #8 0x0000000000557228 in mark_vectorlike (ptr=3D0xb56000) at alloc.c:5377 size =3D 434 i =3D 107 #9 0x0000000000557855 in mark_object (arg=3D11886597) at alloc.c:5569 obj =3D 11886597 cdr_count =3D 0 #10 0x00000000005577b0 in mark_object (arg=3D10786565) at alloc.c:5562 h =3D (struct Lisp_Hash_Table *) 0xa49700 obj =3D 10786565 cdr_count =3D 0 #11 0x00000000005568ff in Fgarbage_collect () at alloc.c:5092 bind =3D (struct specbinding *) 0xb96526 catch =3D (struct catchtag *) 0x7f7fffffc508 handler =3D (struct handler *) 0x10 stack_top_variable =3D 0 '\0' i =3D 418 message_p =3D 0 total =3D {140187732526192, 140187732526008, 140187732526000, 42949= 67295,=20 12148454, 10960258, 10312685, 68} count =3D 8 t1 =3D { tv_sec =3D 1313842937,=20 tv_usec =3D 498976 } t2 =3D { tv_sec =3D 0,=20 tv_usec =3D 140187732530104 } t3 =3D { tv_sec =3D 11465618,=20 tv_usec =3D 0 } #12 0x0000000000577bb4 in Ffuncall (nargs=3D2, args=3D0x7f7fffffc4f0) at ev= al.c:2965 fun =3D 10313885 original_fun =3D 10959186 funcar =3D 10762338 numargs =3D 1 lisp_numargs =3D 10950075 val =3D 68 backtrace =3D { next =3D 0x7f7fffffc9a0,=20 function =3D 0x7f7fffffc4f8,=20 args =3D 0x7f7fffffc500,=20 nargs =3D 1,=20 evalargs =3D 0 '\0',=20 debug_on_exit =3D 0 '\0' } internal_args =3D (Lisp_Object *) 0x7f7fffffc500 i =3D 0 #13 0x00000000005ce3c1 in Fbyte_code (bytestr=3D9300689, vector=3D9300725, = maxdepth=3D12) at bytecode.c:680 count =3D 7 op =3D 1 vectorp =3D (Lisp_Object *) 0x8deb00 bytestr_length =3D 18 stack =3D { pc =3D 0x96972f ")\207",=20 top =3D 0x7f7fffffc4f8,=20 bottom =3D 0x7f7fffffc4f0,=20 byte_string =3D 9300689,=20 byte_string_start =3D 0x96971f "\b\203\b",=20 constants =3D 9300725,=20 next =3D 0x7f7fffffcb40 } top =3D (Lisp_Object *) 0x7f7fffffc4f0 result =3D 10956883 #14 0x00000000005788cc in funcall_lambda (fun=3D9300621, nargs=3D1,=20 arg_vector=3D0x7f7fffffca28) at eval.c:3220 val =3D 10762242 syms_left =3D 10762242 next =3D 18577650 count =3D 6 i =3D 1 optional =3D 0 rest =3D 0 #15 0x000000000057821a in Ffuncall (nargs=3D2, args=3D0x7f7fffffca20) at ev= al.c:3077 fun =3D 9300621 original_fun =3D 18577602 funcar =3D 18577842 numargs =3D 1 lisp_numargs =3D 10956963 val =3D 10762242 backtrace =3D { next =3D 0x7f7fffffced0,=20 function =3D 0x7f7fffffca20,=20 args =3D 0x7f7fffffca28,=20 nargs =3D 1,=20 evalargs =3D 0 '\0',=20 debug_on_exit =3D 0 '\0' } internal_args =3D (Lisp_Object *) 0xa730a3 i =3D 0 #16 0x00000000005ce3c1 in Fbyte_code (bytestr=3D9301185, vector=3D9301221, = maxdepth=3D12) at bytecode.c:680 count =3D 5 op =3D 1 vectorp =3D (Lisp_Object *) 0x8decf0 bytestr_length =3D 31 stack =3D { pc =3D 0x969692 "\v)B\211\034A\n=3D\204\033",=20 top =3D 0x7f7fffffca28,=20 bottom =3D 0x7f7fffffca20,=20 byte_string =3D 9301185,=20 byte_string_start =3D 0x969685 "\b\204\b",=20 constants =3D 9301221,=20 next =3D 0x0 } top =3D (Lisp_Object *) 0x7f7fffffca20 result =3D 10762242 #17 0x00000000005788cc in funcall_lambda (fun=3D9301109, nargs=3D1,=20 arg_vector=3D0x7f7fffffcfa8) at eval.c:3220 val =3D 140187732528832 syms_left =3D 10762242 next =3D 18577650 count =3D 4 i =3D 1 optional =3D 0 rest =3D 0 #18 0x000000000057821a in Ffuncall (nargs=3D2, args=3D0x7f7fffffcfa0) at ev= al.c:3077 fun =3D 9301109 original_fun =3D 11438610 funcar =3D 5059672 numargs =3D 1 lisp_numargs =3D 5059670 val =3D 10762242 backtrace =3D { next =3D 0x7f7fffffd310,=20 function =3D 0x7f7fffffcfa0,=20 args =3D 0x7f7fffffcfa8,=20 nargs =3D 1,=20 evalargs =3D 0 '\0',=20 debug_on_exit =3D 0 '\0' } internal_args =3D (Lisp_Object *) 0xa77993 i =3D 0 #19 0x000000000057296b in Fcall_interactively (function=3D11438610,=20 record_flag=3D10762242, keys=3D10790405) at callint.c:869 val =3D 4 args =3D (Lisp_Object *) 0x7f7fffffcfa0 visargs =3D (Lisp_Object *) 0x7f7fffffcf80 specs =3D 9301281 filter_specs =3D 9301281 teml =3D 5734938 up_event =3D 10762242 enable =3D 10762242 speccount =3D 2 next_event =3D 2 prefix_arg =3D 10762242 string =3D (unsigned char *) 0x7f7fffffcfc0 "P" tem =3D (unsigned char *) 0x61652c "" varies =3D (int *) 0x7f7fffffcf60 i =3D 2 j =3D 1 count =3D 1 foo =3D 1 prompt1 =3D '\0' tem1 =3D 0x0 arg_from_tty =3D 0 gcpro1 =3D { next =3D 0xa43802,=20 var =3D 0xa43802,=20 nvars =3D 0 } gcpro2 =3D { next =3D 0xa53bc2,=20 var =3D 0xa51c05,=20 nvars =3D 10828738 } gcpro3 =3D { next =3D 0xa55952,=20 var =3D 0xa53bc2,=20 nvars =3D 2 } gcpro4 =3D { next =3D 0xa43802,=20 var =3D 0xb4a776,=20 nvars =3D 2 } gcpro5 =3D { next =3D 0xa43802,=20 var =3D 0xa43802,=20 nvars =3D 10836306 } key_count =3D 2 record_then_fail =3D 0 save_this_command =3D 11438610 save_last_command =3D 11490098 save_this_original_command =3D 11438610 save_real_this_command =3D 11438610 #20 0x0000000000577f70 in Ffuncall (nargs=3D4, args=3D0x7f7fffffd3b0) at ev= al.c:3037 fun =3D 10312397 original_fun =3D 10978002 funcar =3D 4294967297 numargs =3D 3 lisp_numargs =3D 10937344 val =3D 315 backtrace =3D { next =3D 0x0,=20 function =3D 0x7f7fffffd3b0,=20 args =3D 0x7f7fffffd3b8,=20 nargs =3D 3,=20 evalargs =3D 0 '\0',=20 debug_on_exit =3D 0 '\0' } internal_args =3D (Lisp_Object *) 0x7f7fffffd3b8 i =3D 0 #21 0x000000000057795d in call3 (fn=3D10978002, arg1=3D11438610, arg2=3D107= 62242,=20 arg3=3D10762242) at eval.c:2857 ret_ungc_val =3D 9301109 gcpro1 =3D { next =3D 0x8dec75,=20 var =3D 0xa43802,=20 nvars =3D 4 } args =3D {10978002, 11438610, 10762242, 10762242} #22 0x00000000004e4bca in Fcommand_execute (cmd=3D11438610, record_flag=3D1= 0762242,=20 keys=3D10762242, special=3D10762242) at keyboard.c:10562 final =3D 9301109 tem =3D 10762242 prefixarg =3D 10762242 #23 0x00000000004d564d in command_loop_1 () at keyboard.c:1906 cmd =3D 11438610 lose =3D 1 keybuf =3D {96, 20, 8, 0, 140187732530800, 18451712, 1893, 0,=20 140187732530816, 1983, 18451712, 4294967317, 140187732530800, 6299742, 10= 656928,=20 216, 10937344, 7378697632079252736, 140187732530864, 9720, 274877896416, = 140187732531032, 0, 140187732530872, 140187732530384, 0, 10762242, 123480= 18,=20 8166853, 10762242} i =3D 2 prev_modiff =3D 158 prev_buffer =3D (struct buffer *) 0xa51c00 already_adjusted =3D 0 #24 0x0000000000575049 in internal_condition_case (bfun=3D0x4d3a17 ,=20 handlers=3D10851522, hfun=3D0x4d34bc ) at eval.c:1492 val =3D 10762242 c =3D { tag =3D 10762242,=20 val =3D 10762242,=20 next =3D 0x7f7fffffd880,=20 gcpro =3D 0x0,=20 jmp =3D {2129, 140187732531264, 140187732541408, 140187698962432, 1401876= 96909296,=20 3, 140187732531000, 5722036, 0, 140187732531488, 18636288},=20 backlist =3D 0x0,=20 handlerlist =3D 0x0,=20 lisp_eval_depth =3D 0,=20 pdlcount =3D 2,=20 poll_suppress_count =3D 0,=20 interrupt_input_blocked =3D 0,=20 byte_stack =3D 0x0 } h =3D { handler =3D 10851522,=20 var =3D 10762242,=20 chosen_clause =3D 0,=20 tag =3D 0x7f7fffffd790,=20 next =3D 0x0 } #25 0x00000000004d389f in command_loop_2 () at keyboard.c:1362 val =3D 1 #26 0x0000000000574a0e in internal_catch (tag=3D10846786,=20 func=3D0x4d3885 , arg=3D10762242) at eval.c:1228 c =3D { tag =3D 10846786,=20 val =3D 10762242,=20 next =3D 0x0,=20 gcpro =3D 0x0,=20 jmp =3D {2129, 140187732531488, 140187732541408, 140187698962432, 1401876= 96909296,=20 3, 140187732531288, 5720565, 4301358603, 10820608, 11046651},=20 backlist =3D 0x0,=20 handlerlist =3D 0x0,=20 lisp_eval_depth =3D 0,=20 pdlcount =3D 2,=20 poll_suppress_count =3D 0,=20 interrupt_input_blocked =3D 0,=20 byte_stack =3D 0x0 } #27 0x00000000004d3859 in command_loop () at keyboard.c:1341 No locals. #28 0x00000000004d3004 in recursive_edit_1 () at keyboard.c:956 count =3D 1 val =3D 5059007 #29 0x00000000004d31a6 in Frecursive_edit () at keyboard.c:1018 count =3D 0 buffer =3D 10762242 #30 0x00000000004d169a in main (argc=3D3, argv=3D0x7f7fffffdb70) at emacs.c= :1833 dummy =3D 140187730444288 stack_bottom_variable =3D 0 '\0' do_initial_setlocale =3D 1 skip_args =3D 0 rlim =3D { rlim_cur =3D 8720384,=20 rlim_max =3D 33554432 } no_loadup =3D 0 junk =3D 0x0 dname_arg =3D 0x0 Lisp Backtrace: "eval-last-sexp-1" (0xffffca28) "eval-last-sexp" (0xffffcfa8) "call-interactively" (0xffffd3b8) --=20 Kazuhiro Ito From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 24 05:40:34 2011 Received: (at 9318) by debbugs.gnu.org; 24 Aug 2011 09:40:34 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qw9wn-0006Mn-VA for submit@debbugs.gnu.org; Wed, 24 Aug 2011 05:40:34 -0400 Received: from msa102.auone-net.jp ([61.117.18.162]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qw9wj-0006Me-SX for 9318@debbugs.gnu.org; Wed, 24 Aug 2011 05:40:32 -0400 Received: from GUNGNIR.med.osaka-cu.ac.jp (unknown [114.179.36.76]) by msa102.auone-net.jp (au one net msa) with ESMTP id 8E190360038; Wed, 24 Aug 2011 18:37:55 +0900 (JST) Date: Wed, 24 Aug 2011 18:37:24 +0900 From: Kazuhiro Ito To: Chong Yidong Subject: Re: bug#9318: 23.3.50; The first call of encode-coding-region() returns wrong result In-Reply-To: <20110821001726.D29052C037@msa104.auone-net.jp> References: <20110818090129.DC129360038@msa102.auone-net.jp> <20110819134637.9727A34803A@msa103.auone-net.jp> <877h67vkpf.fsf@stupidchicken.com> <20110821001726.D29052C037@msa104.auone-net.jp> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 EasyPG/1.0.0 Emacs/23.3.50 (i386-mingw-nt6.1.7601) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Message-Id: <20110824093755.8E190360038@msa102.auone-net.jp> X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 9318 Cc: 9318@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) > I built Emacs 23.3 with "-O0 -g" option on NetBSD 5.1 (amd64), and > started with below commad (via SSH). > > gdb --args emacs -Q --no-splash > > Next, inputtedand below code and evaluated with C-x C-e. > > (progn > (goto-char (point-min)) > (insert #x80) > (insert (make-string 16 ?A)) > (encode-coding-region 1 18 'ctext-unix)) > > backtrace is below. Please let me know if you need more information. > > > Program received signal SIGSEGV, Segmentation fault. > 0x0000000000557419 in mark_object (arg=4702111234474983745) at alloc.c:5473 > 5473 if (STRING_MARKED_P (ptr)) I think relocation of buffer may cause the problem. The comment for CODING_DECODE_CHAR macro in coding.c says as below. > /* This wrapper macro is used to preserve validity of pointers into > buffer text across calls to decode_char, which could cause > relocation of buffers if it loads a charset map, because loading a > charset map allocates large structures. */ encode_coding_iso_2022() uses ENCODE_ISO_CHARACTER macro, which uses ENCODE_CHAR macro. ENCODE_CHAR macro calls encode_char() and it may load a charset map. If this is the cause of the problem, encode_coding_emace_mule() has the same problem. -- Kazuhiro Ito From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 24 08:09:54 2011 Received: (at 9318) by debbugs.gnu.org; 24 Aug 2011 12:09:54 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QwCHK-0008Ac-Gs for submit@debbugs.gnu.org; Wed, 24 Aug 2011 08:09:54 -0400 Received: from mtaout20.012.net.il ([80.179.55.166]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QwCHI-0008AT-74 for 9318@debbugs.gnu.org; Wed, 24 Aug 2011 08:09:53 -0400 Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0LQF00700LF5J600@a-mtaout20.012.net.il> for 9318@debbugs.gnu.org; Wed, 24 Aug 2011 15:06:49 +0300 (IDT) Received: from HOME-C4E4A596F7 ([77.126.219.41]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LQF007A9LN8DN50@a-mtaout20.012.net.il>; Wed, 24 Aug 2011 15:06:47 +0300 (IDT) Date: Wed, 24 Aug 2011 15:06:48 +0300 From: Eli Zaretskii Subject: Re: bug#9318: 23.3.50; The first call of encode-coding-region() returns wrong result In-reply-to: <20110824093755.8E190360038@msa102.auone-net.jp> X-012-Sender: halo1@inter.net.il To: Kazuhiro Ito Message-id: <83ty97ggiv.fsf@gnu.org> References: <20110818090129.DC129360038@msa102.auone-net.jp> <20110819134637.9727A34803A@msa103.auone-net.jp> <877h67vkpf.fsf@stupidchicken.com> <20110821001726.D29052C037@msa104.auone-net.jp> <20110824093755.8E190360038@msa102.auone-net.jp> X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 9318 Cc: cyd@stupidchicken.com, 9318@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) > Date: Wed, 24 Aug 2011 18:37:24 +0900 > From: Kazuhiro Ito > Cc: 9318@debbugs.gnu.org > > > (progn > > (goto-char (point-min)) > > (insert #x80) > > (insert (make-string 16 ?A)) > > (encode-coding-region 1 18 'ctext-unix)) > > > > backtrace is below. Please let me know if you need more information. > > > > > > Program received signal SIGSEGV, Segmentation fault. > > 0x0000000000557419 in mark_object (arg=4702111234474983745) at alloc.c:5473 > > 5473 if (STRING_MARKED_P (ptr)) > > I think relocation of buffer may cause the problem. > > The comment for CODING_DECODE_CHAR macro in coding.c says as below. > > > /* This wrapper macro is used to preserve validity of pointers into > > buffer text across calls to decode_char, which could cause > > relocation of buffers if it loads a charset map, because loading a > > charset map allocates large structures. */ > > encode_coding_iso_2022() uses ENCODE_ISO_CHARACTER macro, which uses > ENCODE_CHAR macro. ENCODE_CHAR macro calls encode_char() and it may > load a charset map. But which pointer(s) in encode_coding_iso_2022 can be altered by relocation? Do you actually see any of the pointers used by this function modified by relocation of some buffer? From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 24 14:02:16 2011 Received: (at 9318) by debbugs.gnu.org; 24 Aug 2011 18:02:16 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QwHmK-0007E1-0A for submit@debbugs.gnu.org; Wed, 24 Aug 2011 14:02:16 -0400 Received: from mail-out.m-online.net ([212.18.0.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QwHmG-0007Dq-JV for 9318@debbugs.gnu.org; Wed, 24 Aug 2011 14:02:14 -0400 Received: from frontend1.mail.m-online.net (frontend1.mail.intern.m-online.net [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 32753188A190; Wed, 24 Aug 2011 19:59:35 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.8.164]) by mail.m-online.net (Postfix) with ESMTP id C7C401C0014B; Wed, 24 Aug 2011 19:59:35 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.180]) by localhost (dynscan1.mail.m-online.net [192.168.8.164]) (amavisd-new, port 10024) with ESMTP id owPUZQOK6m-q; Wed, 24 Aug 2011 19:59:34 +0200 (CEST) Received: from igel.home (ppp-88-217-126-207.dynamic.mnet-online.de [88.217.126.207]) by mail.mnet-online.de (Postfix) with ESMTP; Wed, 24 Aug 2011 19:59:34 +0200 (CEST) Received: by igel.home (Postfix, from userid 501) id 47C0DCA293; Wed, 24 Aug 2011 19:59:34 +0200 (CEST) From: Andreas Schwab To: Kazuhiro Ito Subject: Re: bug#9318: 23.3.50; The first call of encode-coding-region() returns wrong result References: <20110818090129.DC129360038@msa102.auone-net.jp> <20110819134637.9727A34803A@msa103.auone-net.jp> <877h67vkpf.fsf@stupidchicken.com> <20110821001726.D29052C037@msa104.auone-net.jp> <20110824093755.8E190360038@msa102.auone-net.jp> X-Yow: Does that mean I'm not a well-adjusted person?? Date: Wed, 24 Aug 2011 19:59:34 +0200 In-Reply-To: <20110824093755.8E190360038@msa102.auone-net.jp> (Kazuhiro Ito's message of "Wed, 24 Aug 2011 18:37:24 +0900") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 9318 Cc: Chong Yidong , 9318@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) Kazuhiro Ito writes: > I think relocation of buffer may cause the problem. Does that help? diff --git a/src/coding.c b/src/coding.c index 65c8a76..f34a023 100644 --- a/src/coding.c +++ b/src/coding.c @@ -915,8 +915,8 @@ record_conversion_result (struct coding_system *coding, } } -/* This wrapper macro is used to preserve validity of pointers into - buffer text across calls to decode_char, which could cause +/* These wrapper macros are used to preserve validity of pointers into + buffer text across calls to decode_char/encode_char, which could cause relocation of buffers if it loads a charset map, because loading a charset map allocates large structures. */ #define CODING_DECODE_CHAR(coding, src, src_base, src_end, charset, code, c) \ @@ -935,6 +935,21 @@ record_conversion_result (struct coding_system *coding, src_end += offset; \ } \ } while (0) +#define CODING_ENCODE_CHAR(coding, dst, dst_end, charset, c, code) \ + do { \ + charset_map_loaded = 0; \ + code = ENCODE_CHAR (charset, c); \ + if (charset_map_loaded) \ + { \ + const unsigned char *orig = coding->destination; \ + EMACS_INT offset; \ + \ + coding_set_destination (coding); \ + offset = coding->destination - orig; \ + dst += offset; \ + dst_end += offset; \ + } \ + } while (0) /* If there are at least BYTES length of room at dst, allocate memory @@ -2652,7 +2667,7 @@ encode_coding_emacs_mule (struct coding_system *coding) { charset = CHARSET_FROM_ID (preferred_charset_id); if (CHAR_CHARSET_P (c, charset)) - code = ENCODE_CHAR (charset, c); + CODING_ENCODE_CHAR (coding, dst, dst_end, charset, c, code); else charset = char_charset (c, charset_list, &code); } @@ -4185,7 +4200,8 @@ decode_coding_iso_2022 (struct coding_system *coding) #define ENCODE_ISO_CHARACTER(charset, c) \ do { \ - int code = ENCODE_CHAR ((charset), (c)); \ + int code; \ + CODING_ENCODE_CHAR (coding, dst, dst_end, charset, c, code); \ \ if (CHARSET_DIMENSION (charset) == 1) \ ENCODE_ISO_CHARACTER_DIMENSION1 ((charset), code); \ Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 25 05:58:05 2011 Received: (at 9318) by debbugs.gnu.org; 25 Aug 2011 09:58:05 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QwWhH-0004Rj-Qr for submit@debbugs.gnu.org; Thu, 25 Aug 2011 05:58:05 -0400 Received: from msa105.auone-net.jp ([61.117.18.165]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QwWhE-0004RH-BO for 9318@debbugs.gnu.org; Thu, 25 Aug 2011 05:58:02 -0400 Received: from GUNGNIR.med.osaka-cu.ac.jp (unknown [114.179.36.76]) by msa105.auone-net.jp (au one net msa) with ESMTP id F1D042C803A; Thu, 25 Aug 2011 18:55:19 +0900 (JST) Date: Thu, 25 Aug 2011 18:49:52 +0900 From: Kazuhiro Ito To: Eli Zaretskii Subject: Re: bug#9318: 23.3.50; The first call of encode-coding-region() returns wrong result In-Reply-To: <83ty97ggiv.fsf@gnu.org> References: <20110818090129.DC129360038@msa102.auone-net.jp> <20110819134637.9727A34803A@msa103.auone-net.jp> <877h67vkpf.fsf@stupidchicken.com> <20110821001726.D29052C037@msa104.auone-net.jp> <20110824093755.8E190360038@msa102.auone-net.jp> <83ty97ggiv.fsf@gnu.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 EasyPG/1.0.0 Emacs/23.3.50 (i386-mingw-nt6.1.7601) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Message-Id: <20110825095519.F1D042C803A@msa105.auone-net.jp> X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 9318 Cc: 9318@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) > > > (progn > > > (goto-char (point-min)) > > > (insert #x80) > > > (insert (make-string 16 ?A)) > > > (encode-coding-region 1 18 'ctext-unix)) > > > > > > backtrace is below. Please let me know if you need more information. > > > > > > > > > Program received signal SIGSEGV, Segmentation fault. > > > 0x0000000000557419 in mark_object (arg=4702111234474983745) at alloc.c:5473 > > > 5473 if (STRING_MARKED_P (ptr)) > > > > I think relocation of buffer may cause the problem. > > > > The comment for CODING_DECODE_CHAR macro in coding.c says as below. > > > > > /* This wrapper macro is used to preserve validity of pointers into > > > buffer text across calls to decode_char, which could cause > > > relocation of buffers if it loads a charset map, because loading a > > > charset map allocates large structures. */ > > > > encode_coding_iso_2022() uses ENCODE_ISO_CHARACTER macro, which uses > > ENCODE_CHAR macro. ENCODE_CHAR macro calls encode_char() and it may > > load a charset map. > > But which pointer(s) in encode_coding_iso_2022 can be altered by > relocation? encode_coding() sets coding->destination with coding_set_destination() before calling encode_coding_iso_2022(). I think at least correct value of coding->destination can change in encode_coding_iso_2022() by loading charset maps. > Do you actually see any of the pointers used by this > function modified by relocation of some buffer? No, beacuse I don't know how to see. -- Kazuhiro Ito From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 25 05:58:08 2011 Received: (at 9318) by debbugs.gnu.org; 25 Aug 2011 09:58:08 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QwWhM-0004Ry-9G for submit@debbugs.gnu.org; Thu, 25 Aug 2011 05:58:08 -0400 Received: from msa104.auone-net.jp ([61.117.18.164]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QwWhG-0004RS-Vr for 9318@debbugs.gnu.org; Thu, 25 Aug 2011 05:58:06 -0400 Received: from GUNGNIR.med.osaka-cu.ac.jp (unknown [114.179.36.76]) by msa104.auone-net.jp (au one net msa) with ESMTP id 6E2482C037; Thu, 25 Aug 2011 18:55:21 +0900 (JST) Date: Thu, 25 Aug 2011 18:54:13 +0900 From: Kazuhiro Ito To: Andreas Schwab Subject: Re: bug#9318: 23.3.50; The first call of encode-coding-region() returns wrong result In-Reply-To: References: <20110818090129.DC129360038@msa102.auone-net.jp> <20110819134637.9727A34803A@msa103.auone-net.jp> <877h67vkpf.fsf@stupidchicken.com> <20110821001726.D29052C037@msa104.auone-net.jp> <20110824093755.8E190360038@msa102.auone-net.jp> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 EasyPG/1.0.0 Emacs/23.3.50 (i386-mingw-nt6.1.7601) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Message-Id: <20110825095522.6E2482C037@msa104.auone-net.jp> X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 9318 Cc: Eli Zaretskii , Chong Yidong , 9318@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) > > I think relocation of buffer may cause the problem. > > Does that help? > > diff --git a/src/coding.c b/src/coding.c > index 65c8a76..f34a023 100644 > --- a/src/coding.c > +++ b/src/coding.c > @@ -915,8 +915,8 @@ record_conversion_result (struct coding_system *coding, > } > } > > -/* This wrapper macro is used to preserve validity of pointers into > - buffer text across calls to decode_char, which could cause > +/* These wrapper macros are used to preserve validity of pointers into > + buffer text across calls to decode_char/encode_char, which could cause > relocation of buffers if it loads a charset map, because loading a > charset map allocates large structures. */ > #define CODING_DECODE_CHAR(coding, src, src_base, src_end, charset, code, c) \ > @@ -935,6 +935,21 @@ record_conversion_result (struct coding_system *coding, > src_end += offset; \ > } \ > } while (0) > +#define CODING_ENCODE_CHAR(coding, dst, dst_end, charset, c, code) \ > + do { \ > + charset_map_loaded = 0; \ > + code = ENCODE_CHAR (charset, c); \ > + if (charset_map_loaded) \ > + { \ > + const unsigned char *orig = coding->destination; \ > + EMACS_INT offset; \ > + \ > + coding_set_destination (coding); \ > + offset = coding->destination - orig; \ > + dst += offset; \ > + dst_end += offset; \ > + } \ > + } while (0) > > > /* If there are at least BYTES length of room at dst, allocate memory > @@ -2652,7 +2667,7 @@ encode_coding_emacs_mule (struct coding_system *coding) > { > charset = CHARSET_FROM_ID (preferred_charset_id); > if (CHAR_CHARSET_P (c, charset)) > - code = ENCODE_CHAR (charset, c); > + CODING_ENCODE_CHAR (coding, dst, dst_end, charset, c, code); > else > charset = char_charset (c, charset_list, &code); > } > @@ -4185,7 +4200,8 @@ decode_coding_iso_2022 (struct coding_system *coding) > #define ENCODE_ISO_CHARACTER(charset, c) \ > do { \ > - int code = ENCODE_CHAR ((charset), (c)); \ > + int code; \ > + CODING_ENCODE_CHAR (coding, dst, dst_end, charset, c, code); \ > \ > if (CHARSET_DIMENSION (charset) == 1) \ > ENCODE_ISO_CHARACTER_DIMENSION1 ((charset), code); \ Andreas' patch resolved the problem partially. It resolved the problem on NetBSD with '-O0' CFLAGS, but failed on NetBSD with '-O2' and Windows. I confirmed that adding the protection of coding->dst_object to Andreas' patch resolved the problem on NetBSD with '-O2' but not on Windows. I don't know whether it is incorrect way or is not enough. --- src/coding.c 2011-07-01 11:03:55 +0000 +++ src/coding.c 2011-08-24 23:39:49 +0000 @@ -7397,10 +7436,15 @@ setup_ccl_program (&cclspec.ccl, CODING_CCL_ENCODER (coding)); } do { + struct gcpro gcpro1; + GCPRO1 (coding->dst_object); + coding_set_source (coding); consume_chars (coding, translation_table, max_lookup); coding_set_destination (coding); (*(coding->encoder)) (coding); + + UNGCPRO; } while (coding->consumed_char < coding->src_chars); if (BUFFERP (coding->dst_object) && coding->produced_char > 0) -- Kazuhiro Ito From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 26 07:45:30 2011 Received: (at 9318) by debbugs.gnu.org; 26 Aug 2011 11:45:31 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qwuqn-0000wJ-WF for submit@debbugs.gnu.org; Fri, 26 Aug 2011 07:45:30 -0400 Received: from msa101.auone-net.jp ([61.117.18.161]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qwuqk-0000to-8g for 9318@debbugs.gnu.org; Fri, 26 Aug 2011 07:45:28 -0400 Received: from GUNGNIR.med.osaka-cu.ac.jp (EM119-72-249-29.pool.e-mobile.ne.jp [119.72.249.29]) by msa101.auone-net.jp (au one net msa) with ESMTP id 4F8011E0043; Fri, 26 Aug 2011 20:42:34 +0900 (JST) Date: Fri, 26 Aug 2011 20:41:57 +0900 From: Kazuhiro Ito To: Andreas Schwab Subject: Re: bug#9318: 23.3.50; The first call of encode-coding-region() returns wrong result In-Reply-To: <20110825095522.6E2482C037@msa104.auone-net.jp> References: <20110818090129.DC129360038@msa102.auone-net.jp> <20110819134637.9727A34803A@msa103.auone-net.jp> <877h67vkpf.fsf@stupidchicken.com> <20110821001726.D29052C037@msa104.auone-net.jp> <20110824093755.8E190360038@msa102.auone-net.jp> <20110825095522.6E2482C037@msa104.auone-net.jp> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 EasyPG/1.0.0 Emacs/23.3.50 (i386-mingw-nt6.1.7601) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Message-Id: <20110826114235.4F8011E0043@msa101.auone-net.jp> X-Spam-Score: -4.3 (----) X-Debbugs-Envelope-To: 9318 Cc: Eli Zaretskii , Chong Yidong , 9318@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.7 (---) > > > I think relocation of buffer may cause the problem. > > > > Does that help? > > Andreas' patch resolved the problem partially. It resolved the problem on > NetBSD with '-O0' CFLAGS, but failed on NetBSD with '-O2' and Windows. > > I confirmed that adding the protection of coding->dst_object to > Andreas' patch resolved the problem on NetBSD with '-O2' but not on > Windows. I don't know whether it is incorrect way or is not enough. I noticed char_charset() could cause relocation of buffers because it could call encode_char(). I confirmed similar changes to callers of char_charset() fixed my problem (without the protection of coding->dst_object). SUMMARY OF THE PROBLEM: In encode_coding_XXX(), calling encode_char() could cause relocation of buffers. char_charset(), ENCODE_ISO_CHARACTER and ENCODE_CHAR could also cause relocation because they could call encode_char(). After using of them, coding->destination, dst, dst_end should be updated as needed. -- Kazuhiro Ito From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 27 20:08:27 2011 Received: (at 9318) by debbugs.gnu.org; 28 Aug 2011 00:08:27 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QxSvL-0005nQ-Gv for submit@debbugs.gnu.org; Sat, 27 Aug 2011 20:08:27 -0400 Received: from msa101.auone-net.jp ([61.117.18.161]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QxSvH-0005nH-WF for 9318@debbugs.gnu.org; Sat, 27 Aug 2011 20:08:25 -0400 Received: from GUNGNIR.med.osaka-cu.ac.jp (121-87-117-132f1.nar1.eonet.ne.jp [121.87.117.132]) by msa101.auone-net.jp (au one net msa) with ESMTP id 8163B1E0043; Sun, 28 Aug 2011 09:05:27 +0900 (JST) Date: Sun, 28 Aug 2011 09:04:49 +0900 From: Kazuhiro Ito To: Andreas Schwab Subject: Re: bug#9318: 23.3.50; The first call of encode-coding-region() returns wrong result In-Reply-To: <20110826114235.4F8011E0043@msa101.auone-net.jp> References: <20110818090129.DC129360038@msa102.auone-net.jp> <20110819134637.9727A34803A@msa103.auone-net.jp> <877h67vkpf.fsf@stupidchicken.com> <20110821001726.D29052C037@msa104.auone-net.jp> <20110824093755.8E190360038@msa102.auone-net.jp> <20110825095522.6E2482C037@msa104.auone-net.jp> <20110826114235.4F8011E0043@msa101.auone-net.jp> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 EasyPG/1.0.0 Emacs/23.3.50 (i386-mingw-nt6.1.7601) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Message-Id: <20110828000528.8163B1E0043@msa101.auone-net.jp> X-Spam-Score: -3.5 (---) X-Debbugs-Envelope-To: 9318 Cc: Eli Zaretskii , Chong Yidong , 9318@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.4 (---) > SUMMARY OF THE PROBLEM: > In encode_coding_XXX(), calling encode_char() could cause relocation > of buffers. char_charset(), ENCODE_ISO_CHARACTER and ENCODE_CHAR > could also cause relocation because they could call encode_char(). > After using of them, coding->destination, dst, dst_end should be > updated as needed. I noticed CHAR_CHARSET_P macro slipped out of my check. CHAR_CHARSET_P could also cause relocation of buffers. -- Kazuhiro Ito From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 30 19:34:49 2011 Received: (at 9318) by debbugs.gnu.org; 30 Aug 2011 23:34:49 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QyXpQ-0005v6-E4 for submit@debbugs.gnu.org; Tue, 30 Aug 2011 19:34:49 -0400 Received: from msa101.auone-net.jp ([61.117.18.161]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QyXpM-0005uv-7x for 9318@debbugs.gnu.org; Tue, 30 Aug 2011 19:34:47 -0400 Received: from GUNGNIR.med.osaka-cu.ac.jp (unknown [114.179.36.76]) by msa101.auone-net.jp (au one net msa) with ESMTP id C74A61E0043; Wed, 31 Aug 2011 08:31:30 +0900 (JST) Date: Wed, 31 Aug 2011 08:30:47 +0900 From: Kazuhiro Ito To: Andreas Schwab Subject: Re: bug#9318: 23.3.50; The first call of encode-coding-region() returns wrong result In-Reply-To: <20110828000528.8163B1E0043@msa101.auone-net.jp> References: <20110818090129.DC129360038@msa102.auone-net.jp> <20110819134637.9727A34803A@msa103.auone-net.jp> <877h67vkpf.fsf@stupidchicken.com> <20110821001726.D29052C037@msa104.auone-net.jp> <20110824093755.8E190360038@msa102.auone-net.jp> <20110825095522.6E2482C037@msa104.auone-net.jp> <20110826114235.4F8011E0043@msa101.auone-net.jp> <20110828000528.8163B1E0043@msa101.auone-net.jp> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 EasyPG/1.0.0 Emacs/23.3.50 (i386-mingw-nt6.1.7601) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Message-Id: <20110830233131.C74A61E0043@msa101.auone-net.jp> X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 9318 Cc: Eli Zaretskii , Chong Yidong , 9318@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) > > SUMMARY OF THE PROBLEM: > > In encode_coding_XXX(), calling encode_char() could cause relocation > > of buffers. char_charset(), ENCODE_ISO_CHARACTER and ENCODE_CHAR > > could also cause relocation because they could call encode_char(). > > After using of them, coding->destination, dst, dst_end should be > > updated as needed. > > I noticed CHAR_CHARSET_P macro slipped out of my check. > CHAR_CHARSET_P could also cause relocation of buffers. Here is the patch for the code, which contains Andreas' patch. In my environment, problems are fixed. I think it would be better that the interface of encode_designation_at_bol() is changed. === modified file 'src/coding.c' --- src/coding.c 2011-05-09 09:59:23 +0000 +++ src/coding.c 2011-08-28 07:33:54 +0000 @@ -1026,6 +1026,54 @@ } \ } while (0) +#define CODING_ENCODE_CHAR(coding, dst, dst_end, charset, c, code) \ + do { \ + charset_map_loaded = 0; \ + code = ENCODE_CHAR (charset, c); \ + if (charset_map_loaded) \ + { \ + const unsigned char *orig = coding->destination; \ + EMACS_INT offset; \ + \ + coding_set_destination (coding); \ + offset = coding->destination - orig; \ + dst += offset; \ + dst_end += offset; \ + } \ + } while (0) + +#define CODING_CHAR_CHARSET(coding, dst, dst_end, c, charset_list, code_return, charset) \ + do { \ + charset_map_loaded = 0; \ + charset = char_charset (c, charset_list, code_return); \ + if (charset_map_loaded) \ + { \ + const unsigned char *orig = coding->destination; \ + EMACS_INT offset; \ + \ + coding_set_destination (coding); \ + offset = coding->destination - orig; \ + dst += offset; \ + dst_end += offset; \ + } \ + } while (0) + +#define CODING_CHAR_CHARSET_P(coding, dst, dst_end, c, charset, result) \ + do { \ + charset_map_loaded = 0; \ + result = CHAR_CHARSET_P(c, charset); \ + if (charset_map_loaded) \ + { \ + const unsigned char *orig = coding->destination; \ + EMACS_INT offset; \ + \ + coding_set_destination (coding); \ + offset = coding->destination - orig; \ + dst += offset; \ + dst_end += offset; \ + } \ + } while (0) + /* If there are at least BYTES length of room at dst, allocate memory for coding->destination and update dst and dst_end. We don't have @@ -2778,14 +2826,19 @@ if (preferred_charset_id >= 0) { + int result; + charset = CHARSET_FROM_ID (preferred_charset_id); - if (CHAR_CHARSET_P (c, charset)) + CODING_CHAR_CHARSET_P (coding, dst, dst_end, c, charset, result); + if (result) code = ENCODE_CHAR (charset, c); else - charset = char_charset (c, charset_list, &code); + CODING_CHAR_CHARSET(coding, dst, dst_end, c, charset_list, + &code, charset); } else - charset = char_charset (c, charset_list, &code); + CODING_CHAR_CHARSET(coding, dst, dst_end, c, charset_list, + &code, charset); if (! charset) { c = coding->default_char; @@ -2794,7 +2847,8 @@ EMIT_ONE_ASCII_BYTE (c); continue; } - charset = char_charset (c, charset_list, &code); + CODING_CHAR_CHARSET(coding, dst, dst_end, c, charset_list, + &code, charset); } dimension = CHARSET_DIMENSION (charset); emacs_mule_id = CHARSET_EMACS_MULE_ID (charset); @@ -4317,8 +4371,9 @@ #define ENCODE_ISO_CHARACTER(charset, c) \ do { \ - int code = ENCODE_CHAR ((charset),(c)); \ - \ + int code; \ + CODING_ENCODE_CHAR (coding, dst, dst_end, (charset), (c), code); \ + \ if (CHARSET_DIMENSION (charset) == 1) \ ENCODE_ISO_CHARACTER_DIMENSION1 ((charset), code); \ else \ @@ -4476,7 +4531,17 @@ c = *charbuf++; if (c == '\n') break; + + charset_map_loaded = 0; charset = char_charset (c, charset_list, NULL); + if (charset_map_loaded) + { + const unsigned char *orig = coding->destination; + + coding_set_destination (coding); + dst += coding->destination - orig; + } + id = CHARSET_ID (charset); reg = CODING_ISO_REQUEST (coding, id); if (reg >= 0 && r[reg] < 0) @@ -4543,6 +4608,12 @@ /* We have to produce designation sequences if any now. */ dst = encode_designation_at_bol (coding, charbuf, charbuf_end, dst); + if (charset_map_loaded) + { + EMACS_INT offset = coding->destination + coding->dst_bytes - dst_end; + dst_end += offset; + dst_prev += offset; + } bol_designation = 0; /* We are sure that designation sequences are all ASCII bytes. */ produced_chars += dst - dst_prev; @@ -4616,12 +4687,17 @@ if (preferred_charset_id >= 0) { + int result; + charset = CHARSET_FROM_ID (preferred_charset_id); - if (! CHAR_CHARSET_P (c, charset)) - charset = char_charset (c, charset_list, NULL); + CODING_CHAR_CHARSET_P (coding, dst, dst_end, c, charset, result); + if (! result) + CODING_CHAR_CHARSET(coding, dst, dst_end, c, charset_list, + NULL, charset); } else - charset = char_charset (c, charset_list, NULL); + CODING_CHAR_CHARSET(coding, dst, dst_end, c, charset_list, + NULL, charset); if (!charset) { if (coding->mode & CODING_MODE_SAFE_ENCODING) @@ -4632,7 +4708,8 @@ else { c = coding->default_char; - charset = char_charset (c, charset_list, NULL); + CODING_CHAR_CHARSET(coding, dst, dst_end, c, + charset_list, NULL, charset); } } ENCODE_ISO_CHARACTER (charset, c); @@ -5064,7 +5141,9 @@ else { unsigned code; - struct charset *charset = char_charset (c, charset_list, &code); + struct charset *charset; + CODING_CHAR_CHARSET(coding, dst, dst_end, c, charset_list, + &code, charset); if (!charset) { @@ -5076,7 +5155,8 @@ else { c = coding->default_char; - charset = char_charset (c, charset_list, &code); + CODING_CHAR_CHARSET(coding, dst, dst_end, c, + charset_list, &code, charset); } } if (code == CHARSET_INVALID_CODE (charset)) @@ -5153,7 +5233,9 @@ else { unsigned code; - struct charset *charset = char_charset (c, charset_list, &code); + struct charset *charset; + CODING_CHAR_CHARSET(coding, dst, dst_end, c, charset_list, + &code, charset); if (! charset) { @@ -5165,7 +5247,8 @@ else { c = coding->default_char; - charset = char_charset (c, charset_list, &code); + CODING_CHAR_CHARSET(coding, dst, dst_end, c, + charset_list, &code, charset); } } if (code == CHARSET_INVALID_CODE (charset)) @@ -5747,7 +5831,9 @@ } else { - charset = char_charset (c, charset_list, &code); + CODING_CHAR_CHARSET(coding, dst, dst_end, c, charset_list, + &code, charset); + if (charset) { if (CHARSET_DIMENSION (charset) == 1) -- Kazuhiro Ito From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 30 20:56:30 2011 Received: (at 9318) by debbugs.gnu.org; 1 Dec 2011 01:56:30 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RVvt0-0008Ol-7k for submit@debbugs.gnu.org; Wed, 30 Nov 2011 20:56:30 -0500 Received: from mx1.aist.go.jp ([150.29.246.133]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RVvsw-0008Ob-IF for 9318@debbugs.gnu.org; Wed, 30 Nov 2011 20:56:28 -0500 Received: from rqsmtp2.aist.go.jp (rqsmtp2.aist.go.jp [150.29.254.123]) by mx1.aist.go.jp with ESMTP id pB11uE52012360; Thu, 1 Dec 2011 10:56:14 +0900 (JST) env-from (handa@m17n.org) Received: from smtp2.aist.go.jp by rqsmtp2.aist.go.jp with ESMTP id pB11uEbh021807; Thu, 1 Dec 2011 10:56:14 +0900 (JST) env-from (handa@m17n.org) Received: by smtp2.aist.go.jp with ESMTP id pB11uC2C028007; Thu, 1 Dec 2011 10:56:12 +0900 (JST) env-from (handa@m17n.org) From: Kenichi Handa To: Kazuhiro Ito Subject: Re: bug#9318: 23.3.50; The first call of encode-coding-region() returns wrong result In-Reply-To: <20110830233131.C74A61E0043@msa101.auone-net.jp> (message from Kazuhiro Ito on Wed, 31 Aug 2011 08:30:47 +0900) Date: Thu, 01 Dec 2011 10:56:12 +0900 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 9318 Cc: cyd@stupidchicken.com, schwab@linux-m68k.org, 9318@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.8 (--) In article <20110830233131.C74A61E0043@msa101.auone-net.jp>, Kazuhiro Ito writes: > Here is the patch for the code, which contains Andreas' patch. In my > environment, problems are fixed. I think it would be better that the > interface of encode_designation_at_bol() is changed. Oops, sorry, I have vaguely thought that your patch below has already been applied, but just noticed that it was not. I'll commit a slightly modified version including the improved interface for encode_designation_at_bol soon. By the way, it would be good if we had a way to suppress buffer text relocation temporarily. --- Kenichi Handa handa@m17n.org > === modified file 'src/coding.c' > --- src/coding.c 2011-05-09 09:59:23 +0000 > +++ src/coding.c 2011-08-28 07:33:54 +0000 > @@ -1026,6 +1026,54 @@ > } \ > } while (0) > +#define CODING_ENCODE_CHAR(coding, dst, dst_end, charset, c, code) \ > + do { \ > + charset_map_loaded = 0; \ > + code = ENCODE_CHAR (charset, c); \ > + if (charset_map_loaded) \ > + { \ > + const unsigned char *orig = coding->destination; \ > + EMACS_INT offset; \ > + \ > + coding_set_destination (coding); \ > + offset = coding->destination - orig; \ > + dst += offset; \ > + dst_end += offset; \ > + } \ > + } while (0) > + > +#define CODING_CHAR_CHARSET(coding, dst, dst_end, c, charset_list, code_return, charset) \ > + do { \ > + charset_map_loaded = 0; \ > + charset = char_charset (c, charset_list, code_return); \ > + if (charset_map_loaded) \ > + { \ > + const unsigned char *orig = coding->destination; \ > + EMACS_INT offset; \ > + \ > + coding_set_destination (coding); \ > + offset = coding->destination - orig; \ > + dst += offset; \ > + dst_end += offset; \ > + } \ > + } while (0) > + > +#define CODING_CHAR_CHARSET_P(coding, dst, dst_end, c, charset, result) \ > + do { \ > + charset_map_loaded = 0; \ > + result = CHAR_CHARSET_P(c, charset); \ > + if (charset_map_loaded) \ > + { \ > + const unsigned char *orig = coding->destination; \ > + EMACS_INT offset; \ > + \ > + coding_set_destination (coding); \ > + offset = coding->destination - orig; \ > + dst += offset; \ > + dst_end += offset; \ > + } \ > + } while (0) > + > /* If there are at least BYTES length of room at dst, allocate memory > for coding->destination and update dst and dst_end. We don't have > @@ -2778,14 +2826,19 @@ > if (preferred_charset_id >= 0) > { > + int result; > + > charset = CHARSET_FROM_ID (preferred_charset_id); > - if (CHAR_CHARSET_P (c, charset)) > + CODING_CHAR_CHARSET_P (coding, dst, dst_end, c, charset, result); > + if (result) > code = ENCODE_CHAR (charset, c); > else > - charset = char_charset (c, charset_list, &code); > + CODING_CHAR_CHARSET(coding, dst, dst_end, c, charset_list, > + &code, charset); > } > else > - charset = char_charset (c, charset_list, &code); > + CODING_CHAR_CHARSET(coding, dst, dst_end, c, charset_list, > + &code, charset); > if (! charset) > { > c = coding->default_char; > @@ -2794,7 +2847,8 @@ > EMIT_ONE_ASCII_BYTE (c); > continue; > } > - charset = char_charset (c, charset_list, &code); > + CODING_CHAR_CHARSET(coding, dst, dst_end, c, charset_list, > + &code, charset); > } > dimension = CHARSET_DIMENSION (charset); > emacs_mule_id = CHARSET_EMACS_MULE_ID (charset); > @@ -4317,8 +4371,9 @@ > #define ENCODE_ISO_CHARACTER(charset, c) \ > do { \ > - int code = ENCODE_CHAR ((charset),(c)); \ > - \ > + int code; \ > + CODING_ENCODE_CHAR (coding, dst, dst_end, (charset), (c), code); \ > + \ > if (CHARSET_DIMENSION (charset) == 1) \ > ENCODE_ISO_CHARACTER_DIMENSION1 ((charset), code); \ > else \ > @@ -4476,7 +4531,17 @@ > c = *charbuf++; > if (c == '\n') > break; > + > + charset_map_loaded = 0; > charset = char_charset (c, charset_list, NULL); > + if (charset_map_loaded) > + { > + const unsigned char *orig = coding->destination; > + > + coding_set_destination (coding); > + dst += coding->destination - orig; > + } > + > id = CHARSET_ID (charset); > reg = CODING_ISO_REQUEST (coding, id); > if (reg >= 0 && r[reg] < 0) > @@ -4543,6 +4608,12 @@ > /* We have to produce designation sequences if any now. */ > dst = encode_designation_at_bol (coding, charbuf, charbuf_end, dst); > + if (charset_map_loaded) > + { > + EMACS_INT offset = coding->destination + coding->dst_bytes - dst_end; > + dst_end += offset; > + dst_prev += offset; > + } > bol_designation = 0; > /* We are sure that designation sequences are all ASCII bytes. */ > produced_chars += dst - dst_prev; > @@ -4616,12 +4687,17 @@ > if (preferred_charset_id >= 0) > { > + int result; > + > charset = CHARSET_FROM_ID (preferred_charset_id); > - if (! CHAR_CHARSET_P (c, charset)) > - charset = char_charset (c, charset_list, NULL); > + CODING_CHAR_CHARSET_P (coding, dst, dst_end, c, charset, result); > + if (! result) > + CODING_CHAR_CHARSET(coding, dst, dst_end, c, charset_list, > + NULL, charset); > } > else > - charset = char_charset (c, charset_list, NULL); > + CODING_CHAR_CHARSET(coding, dst, dst_end, c, charset_list, > + NULL, charset); > if (!charset) > { > if (coding->mode & CODING_MODE_SAFE_ENCODING) > @@ -4632,7 +4708,8 @@ > else > { > c = coding->default_char; > - charset = char_charset (c, charset_list, NULL); > + CODING_CHAR_CHARSET(coding, dst, dst_end, c, > + charset_list, NULL, charset); > } > } > ENCODE_ISO_CHARACTER (charset, c); > @@ -5064,7 +5141,9 @@ > else > { > unsigned code; > - struct charset *charset = char_charset (c, charset_list, &code); > + struct charset *charset; > + CODING_CHAR_CHARSET(coding, dst, dst_end, c, charset_list, > + &code, charset); > if (!charset) > { > @@ -5076,7 +5155,8 @@ > else > { > c = coding->default_char; > - charset = char_charset (c, charset_list, &code); > + CODING_CHAR_CHARSET(coding, dst, dst_end, c, > + charset_list, &code, charset); > } > } > if (code == CHARSET_INVALID_CODE (charset)) > @@ -5153,7 +5233,9 @@ > else > { > unsigned code; > - struct charset *charset = char_charset (c, charset_list, &code); > + struct charset *charset; > + CODING_CHAR_CHARSET(coding, dst, dst_end, c, charset_list, > + &code, charset); > if (! charset) > { > @@ -5165,7 +5247,8 @@ > else > { > c = coding->default_char; > - charset = char_charset (c, charset_list, &code); > + CODING_CHAR_CHARSET(coding, dst, dst_end, c, > + charset_list, &code, charset); > } > } > if (code == CHARSET_INVALID_CODE (charset)) > @@ -5747,7 +5831,9 @@ > } > else > { > - charset = char_charset (c, charset_list, &code); > + CODING_CHAR_CHARSET(coding, dst, dst_end, c, charset_list, > + &code, charset); > + > if (charset) > { > if (CHARSET_DIMENSION (charset) == 1) > -- > Kazuhiro Ito From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 05 02:10:57 2011 Received: (at 9318) by debbugs.gnu.org; 5 Dec 2011 07:10:57 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RXShU-0005NH-RO for submit@debbugs.gnu.org; Mon, 05 Dec 2011 02:10:57 -0500 Received: from mx1.aist.go.jp ([150.29.246.133]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RXShR-0005N8-IM for 9318@debbugs.gnu.org; Mon, 05 Dec 2011 02:10:56 -0500 Received: from rqsmtp2.aist.go.jp (rqsmtp2.aist.go.jp [150.29.254.123]) by mx1.aist.go.jp with ESMTP id pB57ADKB023640; Mon, 5 Dec 2011 16:10:14 +0900 (JST) env-from (handa@m17n.org) Received: from smtp2.aist.go.jp by rqsmtp2.aist.go.jp with ESMTP id pB57ADVZ006793; Mon, 5 Dec 2011 16:10:13 +0900 (JST) env-from (handa@m17n.org) Received: by smtp2.aist.go.jp with ESMTP id pB57ACVl028557; Mon, 5 Dec 2011 16:10:12 +0900 (JST) env-from (handa@m17n.org) From: Kenichi Handa To: 9318@debbugs.gnu.org Subject: Re: bug#9318: 23.3.50; The first call of encode-coding-region() returns wrong result In-Reply-To: (message from Kenichi Handa on Thu, 01 Dec 2011 10:56:12 +0900) Date: Mon, 05 Dec 2011 16:10:11 +0900 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 9318 Cc: kzhr@d1.dion.ne.jp, schwab@linux-m68k.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.8 (--) In article , Kenichi Handa writes: > In article <20110830233131.C74A61E0043@msa101.auone-net.jp>, Kazuhiro Ito writes: > > Here is the patch for the code, which contains Andreas' patch. In my > > environment, problems are fixed. I think it would be better that the > > interface of encode_designation_at_bol() is changed. > Oops, sorry, I have vaguely thought that your patch below > has already been applied, but just noticed that it was not. > I'll commit a slightly modified version including the > improved interface for encode_designation_at_bol soon. I've just installed the following changes. As I don't have cygwin environment now, could you please check if this change surely fix the problem? --- Kenichi Handa handa@m17n.org 2011-12-05 Kenichi Handa * coding.c (encode_designation_at_bol): New args charbuf_end and dst. Return the number of produced bytes. Callers changed. (coding_set_source): Return how many bytes coding->source was relocated. (coding_set_destination): Return how many bytes coding->destination was relocated. (CODING_DECODE_CHAR, CODING_ENCODE_CHAR, CODING_CHAR_CHARSET) (CODING_CHAR_CHARSET_P): Adjusted for the avove changes. 2011-12-05 Kazuhiro Ito (tiny change) * coding.c (CODING_CHAR_CHARSET_P): New macro. (encode_coding_emacs_mule, encode_coding_iso_2022): Use the above macro (Bug#9318). 2011-12-05 Andreas Schwab The following changes are to fix Bug#9318. * coding.c (CODING_ENCODE_CHAR, CODING_CHAR_CHARSET): New macros. (encode_coding_emacs_mule, ENCODE_ISO_CHARACTER) (encode_coding_iso_2022, encode_coding_sjis) (encode_coding_big5, encode_coding_charset): Use the above macros. === modified file 'src/coding.c' --- src/coding.c 2011-11-07 01:57:07 +0000 +++ src/coding.c 2011-12-05 06:14:46 +0000 @@ -847,16 +847,16 @@ static void decode_coding_raw_text (struct coding_system *); static int encode_coding_raw_text (struct coding_system *); -static void coding_set_source (struct coding_system *); -static void coding_set_destination (struct coding_system *); +static EMACS_INT coding_set_source (struct coding_system *); +static EMACS_INT coding_set_destination (struct coding_system *); static void coding_alloc_by_realloc (struct coding_system *, EMACS_INT); static void coding_alloc_by_making_gap (struct coding_system *, EMACS_INT, EMACS_INT); static unsigned char *alloc_destination (struct coding_system *, EMACS_INT, unsigned char *); static void setup_iso_safe_charsets (Lisp_Object); -static unsigned char *encode_designation_at_bol (struct coding_system *, - int *, unsigned char *); +static int encode_designation_at_bol (struct coding_system *, + int *, int *, unsigned char *); static int detect_eol (const unsigned char *, EMACS_INT, enum coding_category); static Lisp_Object adjust_coding_eol_type (struct coding_system *, int); @@ -915,27 +915,68 @@ } } -/* This wrapper macro is used to preserve validity of pointers into - buffer text across calls to decode_char, which could cause - relocation of buffers if it loads a charset map, because loading a - charset map allocates large structures. */ +/* These wrapper macros are used to preserve validity of pointers into + buffer text across calls to decode_char, encode_char, etc, which + could cause relocation of buffers if it loads a charset map, + because loading a charset map allocates large structures. */ + #define CODING_DECODE_CHAR(coding, src, src_base, src_end, charset, code, c) \ do { \ + EMACS_INT offset; \ + \ charset_map_loaded = 0; \ c = DECODE_CHAR (charset, code); \ - if (charset_map_loaded) \ + if (charset_map_loaded \ + && (offset = coding_set_source (coding))) \ { \ - const unsigned char *orig = coding->source; \ - EMACS_INT offset; \ - \ - coding_set_source (coding); \ - offset = coding->source - orig; \ src += offset; \ src_base += offset; \ src_end += offset; \ } \ } while (0) +#define CODING_ENCODE_CHAR(coding, dst, dst_end, charset, c, code) \ + do { \ + EMACS_INT offset; \ + \ + charset_map_loaded = 0; \ + code = ENCODE_CHAR (charset, c); \ + if (charset_map_loaded \ + && (offset = coding_set_destination (coding))) \ + { \ + dst += offset; \ + dst_end += offset; \ + } \ + } while (0) + +#define CODING_CHAR_CHARSET(coding, dst, dst_end, c, charset_list, code_return, charset) \ + do { \ + EMACS_INT offset; \ + \ + charset_map_loaded = 0; \ + charset = char_charset (c, charset_list, code_return); \ + if (charset_map_loaded \ + && (offset = coding_set_destination (coding))) \ + { \ + dst += offset; \ + dst_end += offset; \ + } \ + } while (0) + +#define CODING_CHAR_CHARSET_P(coding, dst, dst_end, c, charset, result) \ + do { \ + EMACS_INT offset; \ + \ + charset_map_loaded = 0; \ + result = CHAR_CHARSET_P (c, charset); \ + if (charset_map_loaded \ + && (offset = coding_set_destination (coding))) \ + { \ + dst += offset; \ + dst_end += offset; \ + } \ + } while (0) + /* If there are at least BYTES length of room at dst, allocate memory for coding->destination and update dst and dst_end. We don't have @@ -1015,9 +1056,14 @@ | ((p)[-1] & 0x3F)))) -static void +/* Update coding->source from coding->src_object, and return how many + bytes coding->source was changed. */ + +static EMACS_INT coding_set_source (struct coding_system *coding) { + const unsigned char *orig = coding->source; + if (BUFFERP (coding->src_object)) { struct buffer *buf = XBUFFER (coding->src_object); @@ -1036,11 +1082,18 @@ /* Otherwise, the source is C string and is never relocated automatically. Thus we don't have to update anything. */ } + return coding->source - orig; } -static void + +/* Update coding->destination from coding->dst_object, and return how + many bytes coding->destination was changed. */ + +static EMACS_INT coding_set_destination (struct coding_system *coding) { + const unsigned char *orig = coding->destination; + if (BUFFERP (coding->dst_object)) { if (BUFFERP (coding->src_object) && coding->src_pos < 0) @@ -1065,6 +1118,7 @@ /* Otherwise, the destination is C string and is never relocated automatically. Thus we don't have to update anything. */ } + return coding->destination - orig; } @@ -2650,14 +2704,19 @@ if (preferred_charset_id >= 0) { + int result; + charset = CHARSET_FROM_ID (preferred_charset_id); - if (CHAR_CHARSET_P (c, charset)) + CODING_CHAR_CHARSET_P (coding, dst, dst_end, c, charset, result); + if (result) code = ENCODE_CHAR (charset, c); else - charset = char_charset (c, charset_list, &code); + CODING_CHAR_CHARSET (coding, dst, dst_end, c, charset_list, + &code, charset); } else - charset = char_charset (c, charset_list, &code); + CODING_CHAR_CHARSET (coding, dst, dst_end, c, charset_list, + &code, charset); if (! charset) { c = coding->default_char; @@ -2666,7 +2725,8 @@ EMIT_ONE_ASCII_BYTE (c); continue; } - charset = char_charset (c, charset_list, &code); + CODING_CHAR_CHARSET (coding, dst, dst_end, c, charset_list, + &code, charset); } dimension = CHARSET_DIMENSION (charset); emacs_mule_id = CHARSET_EMACS_MULE_ID (charset); @@ -4185,7 +4245,8 @@ #define ENCODE_ISO_CHARACTER(charset, c) \ do { \ - int code = ENCODE_CHAR ((charset), (c)); \ + int code; \ + CODING_ENCODE_CHAR (coding, dst, dst_end, (charset), (c), code); \ \ if (CHARSET_DIMENSION (charset) == 1) \ ENCODE_ISO_CHARACTER_DIMENSION1 ((charset), code); \ @@ -4283,15 +4344,19 @@ /* Produce designation sequences of charsets in the line started from - SRC to a place pointed by DST, and return updated DST. + CHARBUF to a place pointed by DST, and return the number of + produced bytes. DST should not directly point a buffer text area + which may be relocated by char_charset call. If the current block ends before any end-of-line, we may fail to find all the necessary designations. */ -static unsigned char * -encode_designation_at_bol (struct coding_system *coding, int *charbuf, +static int +encode_designation_at_bol (struct coding_system *coding, + int *charbuf, int *charbuf_end, unsigned char *dst) { + unsigned char *orig; struct charset *charset; /* Table of charsets to be designated to each graphic register. */ int r[4]; @@ -4309,7 +4374,7 @@ for (reg = 0; reg < 4; reg++) r[reg] = -1; - while (found < 4) + while (charbuf < charbuf_end && found < 4) { int id; @@ -4334,7 +4399,7 @@ ENCODE_DESIGNATION (CHARSET_FROM_ID (r[reg]), reg, coding); } - return dst; + return dst - orig; } /* See the above "GENERAL NOTES on `encode_coding_XXX ()' functions". */ @@ -4378,13 +4443,26 @@ if (bol_designation) { - unsigned char *dst_prev = dst; - /* We have to produce designation sequences if any now. */ - dst = encode_designation_at_bol (coding, charbuf, dst); - bol_designation = 0; + unsigned char desig_buf[16]; + int nbytes; + EMACS_INT offset; + + charset_map_loaded = 0; + nbytes = encode_designation_at_bol (coding, charbuf, charbuf_end, + desig_buf); + if (charset_map_loaded + && (offset = coding_set_destination (coding))) + { + dst += offset; + dst_end += offset; + } + memcpy (dst, desig_buf, nbytes); + dst += nbytes; /* We are sure that designation sequences are all ASCII bytes. */ - produced_chars += dst - dst_prev; + produced_chars += nbytes; + bol_designation = 0; + ASSURE_DESTINATION (safe_room); } c = *charbuf++; @@ -4455,12 +4533,17 @@ if (preferred_charset_id >= 0) { + int result; + charset = CHARSET_FROM_ID (preferred_charset_id); - if (! CHAR_CHARSET_P (c, charset)) - charset = char_charset (c, charset_list, NULL); + CODING_CHAR_CHARSET_P (coding, dst, dst_end, c, charset, result); + if (! result) + CODING_CHAR_CHARSET (coding, dst, dst_end, c, charset_list, + NULL, charset); } else - charset = char_charset (c, charset_list, NULL); + CODING_CHAR_CHARSET (coding, dst, dst_end, c, charset_list, + NULL, charset); if (!charset) { if (coding->mode & CODING_MODE_SAFE_ENCODING) @@ -4471,7 +4554,8 @@ else { c = coding->default_char; - charset = char_charset (c, charset_list, NULL); + CODING_CHAR_CHARSET (coding, dst, dst_end, c, + charset_list, NULL, charset); } } ENCODE_ISO_CHARACTER (charset, c); @@ -4897,7 +4981,9 @@ else { unsigned code; - struct charset *charset = char_charset (c, charset_list, &code); + struct charset *charset; + CODING_CHAR_CHARSET (coding, dst, dst_end, c, charset_list, + &code, charset); if (!charset) { @@ -4909,7 +4995,8 @@ else { c = coding->default_char; - charset = char_charset (c, charset_list, &code); + CODING_CHAR_CHARSET (coding, dst, dst_end, c, + charset_list, &code, charset); } } if (code == CHARSET_INVALID_CODE (charset)) @@ -4984,7 +5071,9 @@ else { unsigned code; - struct charset *charset = char_charset (c, charset_list, &code); + struct charset *charset; + CODING_CHAR_CHARSET (coding, dst, dst_end, c, charset_list, + &code, charset); if (! charset) { @@ -4996,7 +5085,8 @@ else { c = coding->default_char; - charset = char_charset (c, charset_list, &code); + CODING_CHAR_CHARSET (coding, dst, dst_end, c, + charset_list, &code, charset); } } if (code == CHARSET_INVALID_CODE (charset)) @@ -5572,7 +5662,9 @@ } else { - charset = char_charset (c, charset_list, &code); + CODING_CHAR_CHARSET (coding, dst, dst_end, c, charset_list, + &code, charset); + if (charset) { if (CHARSET_DIMENSION (charset) == 1) From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 05 04:12:31 2011 Received: (at 9318) by debbugs.gnu.org; 5 Dec 2011 09:12:31 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RXUb9-0008Ff-AK for submit@debbugs.gnu.org; Mon, 05 Dec 2011 04:12:31 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RXUb6-0008FW-Rh for 9318@debbugs.gnu.org; Mon, 05 Dec 2011 04:12:30 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id E73AE39E800B; Mon, 5 Dec 2011 01:11:56 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sncBg7NJIn5O; Mon, 5 Dec 2011 01:11:56 -0800 (PST) Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net [71.189.109.235]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 865C839E8008; Mon, 5 Dec 2011 01:11:56 -0800 (PST) Message-ID: <4EDC8AD9.3050004@cs.ucla.edu> Date: Mon, 05 Dec 2011 01:11:53 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111124 Thunderbird/8.0 MIME-Version: 1.0 To: Kenichi Handa Subject: Re: bug#9318: 23.3.50; The first call of encode-coding-region() returns wrong result Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -2.9 (--) X-Debbugs-Envelope-To: 9318 Cc: 9318@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.9 (--) That patch (bzr 106613) causes Emacs to use an uninitialized variable; I found this via static checking with GCC. I installed the following further patch, which I think is right and anyway does not introduce a bug -- can you please check it? Thanks. * coding.c (encode_designation_at_bol): Don't use uninitialized local variable (Bug#9318). === modified file 'src/coding.c' --- src/coding.c 2011-12-05 07:03:31 +0000 +++ src/coding.c 2011-12-05 09:00:44 +0000 @@ -4356,7 +4356,7 @@ int *charbuf, int *charbuf_end, unsigned char *dst) { - unsigned char *orig; + unsigned char *orig = dst; struct charset *charset; /* Table of charsets to be designated to each graphic register. */ int r[4]; From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 05 06:32:30 2011 Received: (at 9318) by debbugs.gnu.org; 5 Dec 2011 11:32:30 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RXWmc-0003BZ-1q for submit@debbugs.gnu.org; Mon, 05 Dec 2011 06:32:30 -0500 Received: from msa104.auone-net.jp ([61.117.18.164]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RXWmX-0003BO-Gl for 9318@debbugs.gnu.org; Mon, 05 Dec 2011 06:32:28 -0500 Received: from GUNGNIR.med.osaka-cu.ac.jp (unknown [114.179.36.76]) by msa104.auone-net.jp (au one net msa) with ESMTP id 338BE2C037; Mon, 5 Dec 2011 20:31:47 +0900 (JST) Date: Mon, 05 Dec 2011 20:31:33 +0900 From: Kazuhiro Ito To: Kenichi Handa Subject: Re: bug#9318: 23.3.50; The first call of encode-coding-region() returns wrong result In-Reply-To: References: User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 EasyPG/1.0.0 Emacs/23.3.50 (i386-mingw-nt6.1.7601) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Message-Id: <20111205113149.338BE2C037@msa104.auone-net.jp> X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 9318 Cc: schwab@linux-m68k.org, 9318@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) > In article , Kenichi Handa writes: > > > In article <20110830233131.C74A61E0043@msa101.auone-net.jp>, Kazuhiro Ito writes: > > > Here is the patch for the code, which contains Andreas' patch. In my > > > environment, problems are fixed. I think it would be better that the > > > interface of encode_designation_at_bol() is changed. > > > Oops, sorry, I have vaguely thought that your patch below > > has already been applied, but just noticed that it was not. > > I'll commit a slightly modified version including the > > improved interface for encode_designation_at_bol soon. > > I've just installed the following changes. As I don't have > cygwin environment now, could you please check if this > change surely fix the problem? As far as I confirmed, the problems were fixed (except the point Paul pointed out). Thank you. Additionally, if you have time, please confirm Bug#8619 and Bug#9389. -- Kazuhiro Ito From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 05 19:31:25 2011 Received: (at 9318) by debbugs.gnu.org; 6 Dec 2011 00:31:25 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RXiwP-0008KK-8d for submit@debbugs.gnu.org; Mon, 05 Dec 2011 19:31:25 -0500 Received: from mx1.aist.go.jp ([150.29.246.133]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RXiwL-0008Jj-2E for 9318@debbugs.gnu.org; Mon, 05 Dec 2011 19:31:23 -0500 Received: from rqsmtp1.aist.go.jp (rqsmtp1.aist.go.jp [150.29.254.115]) by mx1.aist.go.jp with ESMTP id pB60UY7k004413; Tue, 6 Dec 2011 09:30:34 +0900 (JST) env-from (handa@m17n.org) Received: from smtp3.aist.go.jp by rqsmtp1.aist.go.jp with ESMTP id pB60UYFp023773; Tue, 6 Dec 2011 09:30:34 +0900 (JST) env-from (handa@m17n.org) Received: by smtp3.aist.go.jp with ESMTP id pB60UXeD007117; Tue, 6 Dec 2011 09:30:33 +0900 (JST) env-from (handa@m17n.org) From: Kenichi Handa To: Paul Eggert Subject: Re: bug#9318: 23.3.50; The first call of encode-coding-region() returns wrong result In-Reply-To: <4EDC8AD9.3050004@cs.ucla.edu> (message from Paul Eggert on Mon, 05 Dec 2011 01:11:53 -0800) Date: Tue, 06 Dec 2011 09:30:33 +0900 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 9318 Cc: 9318@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.8 (--) In article <4EDC8AD9.3050004@cs.ucla.edu>, Paul Eggert writes: > That patch (bzr 106613) causes Emacs to use an uninitialized variable; > I found this via static checking with GCC. I installed the following > further patch, which I think is right and anyway does not introduce a bug -- > can you please check it? Thanks. Oops, my fault. Yes, your patch is correct. Thank you. --- Kenichi Handa handa@m17n.org > * coding.c (encode_designation_at_bol): Don't use uninitialized > local variable (Bug#9318). > === modified file 'src/coding.c' > --- src/coding.c 2011-12-05 07:03:31 +0000 > +++ src/coding.c 2011-12-05 09:00:44 +0000 > @@ -4356,7 +4356,7 @@ > int *charbuf, int *charbuf_end, > unsigned char *dst) > { > - unsigned char *orig; > + unsigned char *orig = dst; > struct charset *charset; > /* Table of charsets to be designated to each graphic register. */ > int r[4]; From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 06 03:35:45 2011 Received: (at control) by debbugs.gnu.org; 6 Dec 2011 08:35:45 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RXqV7-0004l7-4q for submit@debbugs.gnu.org; Tue, 06 Dec 2011 03:35:45 -0500 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RXqV5-0004l1-UM for control@debbugs.gnu.org; Tue, 06 Dec 2011 03:35:44 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1RXqUU-0000L5-DU for control@debbugs.gnu.org; Tue, 06 Dec 2011 03:35:06 -0500 Date: Tue, 06 Dec 2011 03:35:06 -0500 Message-Id: Subject: control message for bug 9318 To: X-Mailer: mail (GNU Mailutils 2.1) From: Glenn Morris X-Spam-Score: -6.4 (------) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.4 (------) close 9318 24.0.93 From unknown Thu Jun 19 14:11:50 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 03 Jan 2012 12:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator