From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet Newsgroups: gmane.emacs.bugs Subject: bug#52461: spontaneous crash with portable dumper Date: Mon, 13 Dec 2021 14:43:55 +0000 Message-ID: References: <83czm0my1u.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22155"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 52461@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 13 15:45:20 2021 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 1mwmZs-0005Za-NS for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 13 Dec 2021 15:45:20 +0100 Original-Received: from localhost ([::1]:53772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mwmZr-0000on-B7 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 13 Dec 2021 09:45:19 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:47460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mwmZa-0000oV-6x for bug-gnu-emacs@gnu.org; Mon, 13 Dec 2021 09:45:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42946) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mwmZZ-00086s-UN for bug-gnu-emacs@gnu.org; Mon, 13 Dec 2021 09:45:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mwmZZ-0003XU-Qn for bug-gnu-emacs@gnu.org; Mon, 13 Dec 2021 09:45:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Pip Cet Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 13 Dec 2021 14:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52461 X-GNU-PR-Package: emacs Original-Received: via spool by 52461-submit@debbugs.gnu.org id=B52461.163940668713567 (code B ref 52461); Mon, 13 Dec 2021 14:45:01 +0000 Original-Received: (at 52461) by debbugs.gnu.org; 13 Dec 2021 14:44:47 +0000 Original-Received: from localhost ([127.0.0.1]:54492 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mwmZK-0003Wl-Nj for submit@debbugs.gnu.org; Mon, 13 Dec 2021 09:44:46 -0500 Original-Received: from mail-lj1-f181.google.com ([209.85.208.181]:34663) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mwmZG-0003WV-OB for 52461@debbugs.gnu.org; Mon, 13 Dec 2021 09:44:44 -0500 Original-Received: by mail-lj1-f181.google.com with SMTP id k23so24060082lje.1 for <52461@debbugs.gnu.org>; Mon, 13 Dec 2021 06:44:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TI9Plu4Dr/XLAVjB+Io4vl76QTLX6SsKTlrF1pHBq+8=; b=pUCDoCASIRXMaKmZmNTbPdUcLQ2F25syxsyVuRkz+HCuUoGuU9+3qataoSX/W7HRFa 7Yb2cL4iNptnhQPmX64aT33Pzj6JNQ/jH8uDujqiMo/NCH3R45Siki7oCdsCVlUoA0GL cshyE2s6Qllcus8kihrLOwKnabzS4XmDA3f36oHwtk6cUB0ZyHOsVrJbpZ96zVbtJRbD Orbcvj+qx7IsnQNRJBbRJQ3+3P8l1tTh4W/ZLWTzRPy1kgyqK5/xidr3Y2llpTd56I6e 7JFl5jiF44jjiwXCI6aruGUKUjd+utFCP1e0IJvrKsGZzfokYoI5h4us4aXiJnDeGSpy i0VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TI9Plu4Dr/XLAVjB+Io4vl76QTLX6SsKTlrF1pHBq+8=; b=43gf+KSZn/OLtJuERk89hHoqDPXKhJlh19isqXJio7zu+BN5ijnqEjQudBKWYhWZ2K y1SjQ1ynhBP/EtTc0WDJZf01mkjFXpWDybjw9cmKHg6PN9M2/ll3cY9T+Yi1miTpdjHh FrqVfV5HtHPZvs+O6pljrhqEyzv9i3FSeEBYC1hJZ7qOhdMybv+84uEEtrTxVBMq7cvf xdTYSgYRxcihUTtrtwHcIRy1COUWaeTHzZDRjazGC08eQD37UeOED3U2jB3xmCZYV+Ox hwrjam+3RzEXg2/8RpcdE3mpTPS2HZeXGljVY5tutH/LUZZQxyLHXGYppn2ef8BpplXJ bcWw== X-Gm-Message-State: AOAM5300HFKtGSFEYRlVp3S2W629n9bNxjG46xL4GxCJFc3gx1OjMGpW V548p4J2w2gRNmb/R7fkvcbPEM95QGNnd+8GEMY= X-Google-Smtp-Source: ABdhPJyG3HMX1zlSzyKZUdxKbKwKmuDWXRMeem9LMEV2SfIkD2JJvZIh8cZVIRA+3wayoPdLWKfPNT4CVnMDIOoMd/w= X-Received: by 2002:a05:651c:1696:: with SMTP id bd22mr29808676ljb.57.1639406676381; Mon, 13 Dec 2021 06:44:36 -0800 (PST) In-Reply-To: <83czm0my1u.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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:222318 Archived-At: On Mon, Dec 13, 2021 at 1:53 PM Eli Zaretskii wrote: > > Date: Mon, 13 Dec 2021 10:38:28 +0900 > > From: YAMAMOTO Mitsuharu > > > > (lldb) p cs_i > > (int) $2 = 183 > > (lldb) p charset_table_used > > (int) $3 = 183 > > > > Because cs_i >= charset_table_used, charset_table[cs_i] (i.e., *cs) > > contains uninitialized contents. > > So we somehow have a charset that is not in charset_table, is that > what you are saying? Because otherwise how could its ID be beyond the > table, when define-charset-internal enlarges the table as needed? I think there's no great mystery here, and the initial analysis is correct: define-charset-internal enlarges the table, but doesn't zero out the added entries (>= charset_table_used, < charset_table_size). pdumper assumes all entries (< charset_table_size), including the unused ones, contain either valid pointers or NULL. When they're not, but happen to have an invalid pointer in the wrong place, we get a crash. Often, realloc will return zeroed memory so this bug may have stayed invisible for some time. What we can try is debugging the crashing temacs binary, setting a breakpoint to the point where define-charset-internal calls xpalloc (in a very strange manner), at about line 1126 in charset.c, and zero the memory after the call by executing memset (new_table, 0, new_size * sizeof (new_table[0])) in the debugger (I don't use lldb so I'm not sure precisely how to do that), then continuing to the memcpy. If that fixes things, we should make the obvious change, I think. Pip