From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#39207: WITH dgb symbols Re: bug#39207: 28.0.50; crash when sending gnus message Date: Wed, 22 Jan 2020 23:52:08 -0800 Organization: UCLA Computer Science Department Message-ID: References: <87muai8541.fsf@hillenius.net> <87eevt5gbi.fsf@hillenius.net> <87tv4pdu0u.fsf@hillenius.net> <871rrtvzgi.fsf@hillenius.net> <83h80ox1i1.fsf@gnu.org> <87k15kx010.fsf@hillenius.net> <87muag7yf3.fsf@hillenius.net> <87lfpzsvq5.fsf@hillenius.net> <83a76fv58n.fsf@gnu.org> <83v9p3tmtb.fsf@gnu.org> <87ftg7urdu.fsf@igel.home> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------80365349C349E032FAF5857D" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="117930"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 Cc: Robert Pluim , 39207@debbugs.gnu.org, =?UTF-8?Q?G=C4=B3s?= Hillenius To: Andreas Schwab Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 23 08:57:53 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iuXNA-000Ud5-Ew for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 23 Jan 2020 08:57:52 +0100 Original-Received: from localhost ([::1]:52476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXN9-0006mO-IL for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 23 Jan 2020 02:57:51 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46812) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXIV-0001hs-7W for bug-gnu-emacs@gnu.org; Thu, 23 Jan 2020 02:53:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXIT-0007ZQ-RT for bug-gnu-emacs@gnu.org; Thu, 23 Jan 2020 02:53:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45694) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iuXIT-0007ZI-Nn for bug-gnu-emacs@gnu.org; Thu, 23 Jan 2020 02:53:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iuXIT-0003Oc-NP for bug-gnu-emacs@gnu.org; Thu, 23 Jan 2020 02:53:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 23 Jan 2020 07:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39207 X-GNU-PR-Package: emacs Original-Received: via spool by 39207-submit@debbugs.gnu.org id=B39207.157976593913006 (code B ref 39207); Thu, 23 Jan 2020 07:53:01 +0000 Original-Received: (at 39207) by debbugs.gnu.org; 23 Jan 2020 07:52:19 +0000 Original-Received: from localhost ([127.0.0.1]:51667 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iuXHm-0003Ni-Ow for submit@debbugs.gnu.org; Thu, 23 Jan 2020 02:52:19 -0500 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:53952) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iuXHj-0003NU-OJ for 39207@debbugs.gnu.org; Thu, 23 Jan 2020 02:52:17 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 12BEC16006A; Wed, 22 Jan 2020 23:52:10 -0800 (PST) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id U3uWmbA5IaQT; Wed, 22 Jan 2020 23:52:09 -0800 (PST) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 0A2B2160081; Wed, 22 Jan 2020 23:52:09 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id NzoID0prtnIU; Wed, 22 Jan 2020 23:52:08 -0800 (PST) Original-Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id B22C816006A; Wed, 22 Jan 2020 23:52:08 -0800 (PST) In-Reply-To: <87ftg7urdu.fsf@igel.home> Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:175135 Archived-At: This is a multi-part message in MIME format. --------------80365349C349E032FAF5857D Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 1/22/20 1:13 PM, Andreas Schwab wrote: > Looks like aset has been broken by commit c1b6d5c5b9 or ac121d8c8f. Thanks for the heads-up and the test case. Sorry about the breakage. I installed the attached patch, which I assume fixes this. --------------80365349C349E032FAF5857D Content-Type: text/x-patch; charset=UTF-8; name="0001-Fix-crash-when-sending-Gnus-message-Bug-39207.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Fix-crash-when-sending-Gnus-message-Bug-39207.patch" >From 6f580542c1796d3e7ba4d1dd40b2fe73fe00e5db Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 22 Jan 2020 23:43:29 -0800 Subject: [PATCH] Fix crash when sending Gnus message (Bug#39207) * src/alloc.c (resize_string_data): The string must be multibyte. When not bothering to reallocate, do bother to change the byte count. * test/src/alloc-tests.el (aset-nbytes-change) New test. --- src/alloc.c | 4 +++- test/src/alloc-tests.el | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/alloc.c b/src/alloc.c index 99d5ca149d..a35b48cfb2 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1889,7 +1889,7 @@ allocate_string_data (struct Lisp_String *s, tally_consing (needed); } -/* Reallocate the data for STRING when a single character is replaced. +/* Reallocate multibyte STRING data when a single character is replaced. The character is at byte offset CIDX_BYTE in the string. The character being replaced is CLEN bytes long, and the character that will replace it is NEW_CLEN bytes long. @@ -1900,6 +1900,7 @@ unsigned char * resize_string_data (Lisp_Object string, ptrdiff_t cidx_byte, int clen, int new_clen) { + eassume (STRING_MULTIBYTE (string)); sdata *old_sdata = SDATA_OF_STRING (XSTRING (string)); ptrdiff_t nchars = SCHARS (string); ptrdiff_t nbytes = SBYTES (string); @@ -1911,6 +1912,7 @@ resize_string_data (Lisp_Object string, ptrdiff_t cidx_byte, { /* No need to reallocate, as the size change falls within the alignment slop. */ + XSTRING (string)->u.s.size_byte = new_nbytes; new_charaddr = data + cidx_byte; memmove (new_charaddr + new_clen, new_charaddr + clen, nbytes - (cidx_byte + (clen - 1))); diff --git a/test/src/alloc-tests.el b/test/src/alloc-tests.el index 4eb776a055..aa1ab1648f 100644 --- a/test/src/alloc-tests.el +++ b/test/src/alloc-tests.el @@ -51,3 +51,10 @@ (should-not (eq x y)) (dotimes (i 4) (should (eql (aref x i) (aref y i)))))) + +;; Bug#39207 +(ert-deftest aset-nbytes-change () + (let ((s (make-string 1 ?a))) + (dolist (c (list 10003 ?b 128 ?c ?d (max-char) ?e)) + (aset s 0 c) + (should (equal s (make-string 1 c)))))) -- 2.17.1 --------------80365349C349E032FAF5857D--