From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 04 19:09:26 2022 Received: (at submit) by debbugs.gnu.org; 4 Nov 2022 23:09:26 +0000 Received: from localhost ([127.0.0.1]:55051 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1or5oT-0001Nn-Pv for submit@debbugs.gnu.org; Fri, 04 Nov 2022 19:09:26 -0400 Received: from lists.gnu.org ([209.51.188.17]:41244) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1or5oQ-0001NY-Vh for submit@debbugs.gnu.org; Fri, 04 Nov 2022 19:09:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1or5oQ-0008Sx-RW for bug-gnu-emacs@gnu.org; Fri, 04 Nov 2022 19:09:22 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1or5oN-0005wi-Va for bug-gnu-emacs@gnu.org; Fri, 04 Nov 2022 19:09:22 -0400 Received: (Authenticated sender: matt@rfc20.org) by mail.gandi.net (Postfix) with ESMTPSA id A2FF820003 for ; Fri, 4 Nov 2022 23:09:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rfc20.org; s=gm1; t=1667603355; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=7rz1iVY55ljXo90EY8HgLkeOeR9W+x92XHpS0cv4xN0=; b=okZlgP/04vnqJF4usJfWcZ0Z3KobR0ezeO+kCV637kzy2KB5s8Tsyqv77aISj03UyYcA8Q 9kkD/bw+oXRnNBwtCzukSQMtxPAT9KxFjxHaudhuasAzbaa3dCwAjaF37JZz/VlkfUXt+S Ahc3fX7BNeTHhf1UV23okHphnNHgOv9I5zlZWO0aACDG30xyBzfoYUhrLO1GkQeRtAJtCQ e5dOpYb+lUSIpRopdhmM/hprQQSAlnBuQjaIoGZYCqYktxRKAgTgQZKftvoUxFVG9yrEcA hDuOUKbV5f9/Lr0cdtN4Y/iZnzFRhGCfUaNPEEPc95TarMFqMqqZNkTO9chVtw== Received: from matt by naz with local (Exim 4.96) (envelope-from ) id 1or5oF-002BZ2-2d for bug-gnu-emacs@gnu.org; Fri, 04 Nov 2022 16:09:11 -0700 From: Matt Armstrong To: bug-gnu-emacs@gnu.org Subject: 29.0.50; noverlay: pdumper.c: dump_interval_node recursion has no base case Date: Fri, 04 Nov 2022 16:09:11 -0700 Message-ID: <87leoqwc4o.fsf@rfc20.org> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=217.70.183.200; envelope-from=matt@rfc20.org; helo=relay7-d.mail.gandi.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) X-Debbugs-cc: Stefan Monnier This has been in my head for weeks but I haven't had time to dig into it. Best get it in a bug. See the code for dump_interval_node() in pdumper.c below. Imagine 'node' has a left child. It will recurse to that child on line 35. That child will recurse back to its parent on line 30. That parent will recurse back to its left child on line 35. This will repeat until the stack blows. All you need is two nodes in the tree. This is not an immediate issue today because apparently Emacs does not dump any buffers with overlays present, or at least, never more than one overlay. I suspect the right fix is to delete lines 26-30, or something like that, but I can't claim I understand this code. 1 static dump_off 2 dump_interval_node (struct dump_context *ctx, struct itree_node *node, 3 dump_off parent_offset) 4 { 5 #if CHECK_STRUCTS && !defined (HASH_itree_node_50DE304F13) 6 # error "itree_node changed. See CHECK_STRUCTS comment in config.h." 7 #endif 8 struct itree_node out; 9 dump_object_start (ctx, &out, sizeof (out)); 10 if (node->parent) 11 dump_field_fixup_later (ctx, &out, node, &node->parent); 12 if (node->left) 13 dump_field_fixup_later (ctx, &out, node, &node->parent); 14 if (node->right) 15 dump_field_fixup_later (ctx, &out, node, &node->parent); 16 DUMP_FIELD_COPY (&out, node, begin); 17 DUMP_FIELD_COPY (&out, node, end); 18 DUMP_FIELD_COPY (&out, node, limit); 19 DUMP_FIELD_COPY (&out, node, offset); 20 DUMP_FIELD_COPY (&out, node, otick); 21 dump_field_lv (ctx, &out, node, &node->data, WEIGHT_STRONG); 22 DUMP_FIELD_COPY (&out, node, red); 23 DUMP_FIELD_COPY (&out, node, rear_advance); 24 DUMP_FIELD_COPY (&out, node, front_advance); 25 dump_off offset = dump_object_finish (ctx, &out, sizeof (out)); 26 if (node->parent) 27 dump_remember_fixup_ptr_raw 28 (ctx, 29 offset + dump_offsetof (struct itree_node, parent), 30 dump_interval_node (ctx, node->parent, offset)); 31 if (node->left) 32 dump_remember_fixup_ptr_raw 33 (ctx, 34 offset + dump_offsetof (struct itree_node, left), 35 dump_interval_node (ctx, node->left, offset)); 36 if (node->right) 37 dump_remember_fixup_ptr_raw 38 (ctx, 39 offset + dump_offsetof (struct itree_node, right), 40 dump_interval_node (ctx, node->right, offset)); 41 return offset; 42 } From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 05 01:41:53 2022 Received: (at 59029) by debbugs.gnu.org; 5 Nov 2022 05:41:53 +0000 Received: from localhost ([127.0.0.1]:55313 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1orBwG-0003uN-LT for submit@debbugs.gnu.org; Sat, 05 Nov 2022 01:41:53 -0400 Received: from mail-ed1-f48.google.com ([209.85.208.48]:39462) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1orBwD-0003u2-18 for 59029@debbugs.gnu.org; Sat, 05 Nov 2022 01:41:50 -0400 Received: by mail-ed1-f48.google.com with SMTP id f7so10350645edc.6 for <59029@debbugs.gnu.org>; Fri, 04 Nov 2022 22:41:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=JLx5uQU6POKTXM1+DX38rzmmgN8lknzYRrgfAACpD/o=; b=EOOsKX5hyIjYCIJI8yfb88jmklgEIfgScvm7aoG7BKjlTr/f6/XQNky5sjazNfjRUO uw6y069mysm1FB4LD2vGZT2VIB+QL+2ekRfUA0uJaGweVOr2TaxoKE6hQzWq4yThq0s+ iijXV1NhK/L+Vc2M+IJt+q5rfh02FHaPq3NQPPEtsG9xDuWhXabk8+NuN7aR4jPSrtAv wguasFLzpV8vea21TaE+NeOLY6pQfEWyF64nOrg9NVa+P3wO4v8VEc1Z/AbWNFsKRKCr kl08D8Yz2n1MbjwlNTwQ6jr6g1kVCtLePQl0sJ6b2sY+1TxXOAmbNApqFr5qUeeBA+GB goAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=JLx5uQU6POKTXM1+DX38rzmmgN8lknzYRrgfAACpD/o=; b=LVEQ/mK5sxpjcNaeEPXOFLjDHDAJSJNQrof6yIOzL1eltsxDzkndcxQQ65Bqt9zHSM nR0kRuCkJcvhhFiYmDduBvqEt0C2zKwoJViOGO0ZQI5RmrLgCDslOeN0CCn7znMA/r94 tKDw9Iq3HMa4SeS4JDdU30F6YJ+7IzAAhI5DOGSQfgKKUt9hkxRIxC57SFIRN8rarIRy TVQDXCLh3ZcLSX2cON5EkDzdEdZFkUohslmCm0NxNH+ipcyQKiMEMPeMLkAdyFH6W19Y 9upBHup+txKnyJvPBVbXJS0gF78hf1hK3wWPiF/4w9fEad4dKKKyXbsPuhpIVb/u+VUN JCHA== X-Gm-Message-State: ACrzQf0lt61qLP1VGXRl1hRua+BmPWTrZYPJBjGwkZPti+WJSh06fiOY FR8ASiAm9QP1wCQ7xPMQx/4= X-Google-Smtp-Source: AMsMyM7m47wneVPXBji304x1Ap+UGunj42IvrUR8m7YskZ3J6UWS7BiPQL1KqAQeHIdfYqaCmz6tEg== X-Received: by 2002:a05:6402:1004:b0:464:778:c516 with SMTP id c4-20020a056402100400b004640778c516mr17098805edu.348.1667626902987; Fri, 04 Nov 2022 22:41:42 -0700 (PDT) Received: from Mini.fritz.box (p4fe3a85e.dip0.t-ipconnect.de. [79.227.168.94]) by smtp.gmail.com with ESMTPSA id x14-20020a170906134e00b0073022b796a7sm461927ejb.93.2022.11.04.22.41.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 22:41:42 -0700 (PDT) From: =?utf-8?Q?Gerd_M=C3=B6llmann?= To: Matt Armstrong Subject: Re: bug#59029: 29.0.50; noverlay: pdumper.c: dump_interval_node recursion has no base case In-Reply-To: <87leoqwc4o.fsf@rfc20.org> (Matt Armstrong's message of "Fri, 04 Nov 2022 16:09:11 -0700") References: <87leoqwc4o.fsf@rfc20.org> Date: Sat, 05 Nov 2022 06:41:41 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 59029 Cc: 59029@debbugs.gnu.org, stefan monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Matt Armstrong writes: > X-Debbugs-cc: Stefan Monnier > > This has been in my head for weeks but I haven't had time to dig into > it. Best get it in a bug. > > See the code for dump_interval_node() in pdumper.c below. > > Imagine 'node' has a left child. It will recurse to that child on line > 35. That child will recurse back to its parent on line 30. That parent > will recurse back to its left child on line 35. This will repeat until > the stack blows. All you need is two nodes in the tree. > > This is not an immediate issue today because apparently Emacs does not > dump any buffers with overlays present, or at least, never more than one > overlay. I suspect the right fix is to delete lines 26-30, or something > like that, but I can't claim I understand this code. > > 1 static dump_off > 2 dump_interval_node (struct dump_context *ctx, struct itree_node *node, > 3 dump_off parent_offset) > 4 { > 5 #if CHECK_STRUCTS && !defined (HASH_itree_node_50DE304F13) > 6 # error "itree_node changed. See CHECK_STRUCTS comment in config.h." > 7 #endif > 8 struct itree_node out; > 9 dump_object_start (ctx, &out, sizeof (out)); > 10 if (node->parent) > 11 dump_field_fixup_later (ctx, &out, node, &node->parent); > 12 if (node->left) > 13 dump_field_fixup_later (ctx, &out, node, &node->parent); > 14 if (node->right) > 15 dump_field_fixup_later (ctx, &out, node, &node->parent); > 16 DUMP_FIELD_COPY (&out, node, begin); > 17 DUMP_FIELD_COPY (&out, node, end); > 18 DUMP_FIELD_COPY (&out, node, limit); > 19 DUMP_FIELD_COPY (&out, node, offset); > 20 DUMP_FIELD_COPY (&out, node, otick); > 21 dump_field_lv (ctx, &out, node, &node->data, WEIGHT_STRONG); > 22 DUMP_FIELD_COPY (&out, node, red); > 23 DUMP_FIELD_COPY (&out, node, rear_advance); > 24 DUMP_FIELD_COPY (&out, node, front_advance); > 25 dump_off offset = dump_object_finish (ctx, &out, sizeof (out)); > 26 if (node->parent) > 27 dump_remember_fixup_ptr_raw > 28 (ctx, > 29 offset + dump_offsetof (struct itree_node, parent), > 30 dump_interval_node (ctx, node->parent, offset)); > 31 if (node->left) > 32 dump_remember_fixup_ptr_raw > 33 (ctx, > 34 offset + dump_offsetof (struct itree_node, left), > 35 dump_interval_node (ctx, node->left, offset)); > 36 if (node->right) > 37 dump_remember_fixup_ptr_raw > 38 (ctx, > 39 offset + dump_offsetof (struct itree_node, right), > 40 dump_interval_node (ctx, node->right, offset)); > 41 return offset; > 42 } Yes, I think you are right. Could we also rename dump_interval_node to dump_itree_node? There is another function dump_interval_tree for text properties, which is a bit confusing. From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 05 14:07:09 2022 Received: (at control) by debbugs.gnu.org; 5 Nov 2022 18:07:09 +0000 Received: from localhost ([127.0.0.1]:58000 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1orNZV-0001jv-2O for submit@debbugs.gnu.org; Sat, 05 Nov 2022 14:07:09 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:43187) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1orNZR-0001jL-Q4 for control@debbugs.gnu.org; Sat, 05 Nov 2022 14:07:07 -0400 Received: (Authenticated sender: matt@rfc20.org) by mail.gandi.net (Postfix) with ESMTPSA id 3FE8C20007 for ; Sat, 5 Nov 2022 18:06:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rfc20.org; s=gm1; t=1667671619; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=UXlInj+V1fxYGo5FcoRXxfPcWoX/j7Dw1swOGvFRQBc=; b=JvK+5uJRGPxNZWbmS9IXkyyqwPNRlevHT9Z62gTh5kDs9ckCFOqL9JKIr5gZX8m3RguObB zd7+vCLcMieNOgPoHaApzus923p9oHngtq1u4tJAJ4qXKv4Sp51LqUsjsAYzlbX7SomFNm LGO5+eY0UK+k1VXr7otEMBOhGZDw3j4AD4Zm221jJf59Miu5NxY7Zy11C7QOjqcEPsHWzI TAJw0i1mPIunWpHdGVXwNQTwvmH9gQcx00jblWArv7g1/JXoa7C7NTcjEerXPlSezgsyjc a7jA8nv74aXjOL++xTgdzHonXh8aJV7Q2hzb9RdfDvy4WAGwIi2/tsVgaG+89A== Received: from matt by naz with local (Exim 4.96) (envelope-from ) id 1orNZH-0006Bs-1i for control@debbugs.gnu.org; Sat, 05 Nov 2022 11:06:55 -0700 From: Matt Armstrong To: control@debbugs.gnu.org Subject: control message for bug #59029 Date: Sat, 05 Nov 2022 11:06:55 -0700 Message-ID: <87h6zdwa0w.fsf@rfc20.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) retitle 59029 Dumping Emacs crashes when buffers have overlays quit From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 05 14:09:42 2022 Received: (at 59029) by debbugs.gnu.org; 5 Nov 2022 18:09:42 +0000 Received: from localhost ([127.0.0.1]:58009 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1orNbx-0001nl-Uu for submit@debbugs.gnu.org; Sat, 05 Nov 2022 14:09:42 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:43737) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1orNbv-0001nY-RS for 59029@debbugs.gnu.org; Sat, 05 Nov 2022 14:09:40 -0400 Received: (Authenticated sender: matt@rfc20.org) by mail.gandi.net (Postfix) with ESMTPSA id B141AE0012; Sat, 5 Nov 2022 18:09:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rfc20.org; s=gm1; t=1667671773; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=U8uwAOw0FutMcHWwd3vPawsZ8z90Pm0lPQcCIdVcEqY=; b=IqUxkmDRqdEjcmRTpDrogBTUEAt5/ROVUVWc6wWKq0v5YD87pMB9I99fgjGAl3ExLsUzPm lL+iDLS3wSlOByp45huNNpUSzqpFiTt/vPObOvwIfBfzW8tja6DA9cTOOtgt9DEIemETME e0mHdPggyO3k2JIYyiIhkNGQphBb/+V9dNod7Ym10bFxppnWfDlG9rzAw26P4IVfBolP7N JM7xQD9CSTyxVNO5VauKnwaJLxzPecL7bNQQKLU0qPd8cKBDU4vLhMERddYRCVB4kOcmo3 b1UFf4wmRomDAjcNpIZ+nPkSV0y9Xss6zOXV/YirOKkPREm3Z2BHydRG7kg/uw== Received: from matt by naz with local (Exim 4.96) (envelope-from ) id 1orNbl-0006Cm-34; Sat, 05 Nov 2022 11:09:29 -0700 From: Matt Armstrong To: Gerd =?utf-8?Q?M=C3=B6llmann?= Subject: Re: bug#59029: 29.0.50; noverlay: pdumper.c: dump_interval_node recursion has no base case In-Reply-To: ("Gerd =?utf-8?Q?M=C3=B6llman?= =?utf-8?Q?n=22's?= message of "Sat, 05 Nov 2022 06:41:41 +0100") References: <87leoqwc4o.fsf@rfc20.org> Date: Sat, 05 Nov 2022 11:09:29 -0700 Message-ID: <87cza1w9wm.fsf@rfc20.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 59029 Cc: 59029@debbugs.gnu.org, stefan monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Gerd M=C3=B6llmann writes: > Yes, I think you are right. > > Could we also rename dump_interval_node to dump_itree_node? There is > another function dump_interval_tree for text properties, which is a bit > confusing. Attached renames the function and tags two related FIXMEs with this bug number. The root issue is that pdumping buffers with overlays is not implemented. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0005-Add-FIXME-comments-for-overlays.patch >From 82c448f7f6eda810114151b5339d500fd6cf5826 Mon Sep 17 00:00:00 2001 From: Matt Armstrong Date: Sat, 5 Nov 2022 11:03:09 -0700 Subject: [PATCH 5/5] Add FIXME comments for overlays. * src/pdumper.c (dump_itree_node): Renamed from dump_interval_node. Add FIXME(Matt): comment for bug#59029. (dump_buffer): Tag comment with FIXME bug#59029. --- src/pdumper.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/pdumper.c b/src/pdumper.c index 0a5d96dbb7c..10b6f58bbd8 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -2134,8 +2134,8 @@ dump_marker (struct dump_context *ctx, const struct Lisp_Marker *marker) } static dump_off -dump_interval_node (struct dump_context *ctx, struct itree_node *node, - dump_off parent_offset) +dump_itree_node (struct dump_context *ctx, struct itree_node *node, + dump_off parent_offset) { #if CHECK_STRUCTS && !defined (HASH_itree_node_50DE304F13) # error "itree_node changed. See CHECK_STRUCTS comment in config.h." @@ -2158,21 +2158,25 @@ dump_interval_node (struct dump_context *ctx, struct itree_node *node, DUMP_FIELD_COPY (&out, node, rear_advance); DUMP_FIELD_COPY (&out, node, front_advance); dump_off offset = dump_object_finish (ctx, &out, sizeof (out)); + /* FIXME: bug#59029 We haven't implemented the code to dump overlays + that are part of a buffer. The code below will recurse forever + if any of parent, left or right is non-NULL, but isn't worth + changing until we have a test case. */ if (node->parent) dump_remember_fixup_ptr_raw (ctx, offset + dump_offsetof (struct itree_node, parent), - dump_interval_node (ctx, node->parent, offset)); + dump_itree_node (ctx, node->parent, offset)); if (node->left) dump_remember_fixup_ptr_raw (ctx, offset + dump_offsetof (struct itree_node, left), - dump_interval_node (ctx, node->left, offset)); + dump_itree_node (ctx, node->left, offset)); if (node->right) dump_remember_fixup_ptr_raw (ctx, offset + dump_offsetof (struct itree_node, right), - dump_interval_node (ctx, node->right, offset)); + dump_itree_node (ctx, node->right, offset)); return offset; } @@ -2189,7 +2193,7 @@ dump_overlay (struct dump_context *ctx, const struct Lisp_Overlay *overlay) dump_remember_fixup_ptr_raw (ctx, offset + dump_offsetof (struct Lisp_Overlay, interval), - dump_interval_node (ctx, overlay->interval, offset)); + dump_itree_node (ctx, overlay->interval, offset)); return offset; } @@ -2864,7 +2868,8 @@ dump_buffer (struct dump_context *ctx, const struct buffer *in_buffer) DUMP_FIELD_COPY (out, buffer, long_line_optimizations_p); if (buffer->overlays && buffer->overlays->root != NULL) - /* We haven't implemented the code to dump overlays. */ + /* FIXME: bug#59029 We haven't implemented the code to dump + overlays that are in a buffer. */ emacs_abort (); else out->overlays = NULL; -- 2.35.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 05 15:32:37 2022 Received: (at control) by debbugs.gnu.org; 5 Nov 2022 19:32:37 +0000 Received: from localhost ([127.0.0.1]:58099 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1orOuD-00063y-Cg for submit@debbugs.gnu.org; Sat, 05 Nov 2022 15:32:37 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:45861) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1orOu9-00063f-NB for control@debbugs.gnu.org; Sat, 05 Nov 2022 15:32:35 -0400 Received: (Authenticated sender: matt@rfc20.org) by mail.gandi.net (Postfix) with ESMTPSA id 54E4EFF808 for ; Sat, 5 Nov 2022 19:32:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rfc20.org; s=gm1; t=1667676747; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc; bh=SBKWag1huvscW8aKSINueihssY4dRMEzrheD16Rmg8Y=; b=PeqLwJ16ZJf3FPboIcXNd5fCEnxbHV0U/wW+h0GSqPZAyBHzVFaHYGgtPJPARPMe7blX4/ hoyN4ps+Wq6OxvmBKapzXLqIiCjH72zvR8S+cnoH9B2F2o2+2c7Zs74Y+0+yMoo9t9nFxb 0q+UXrA0sq9O+/D2sB+0ruAyOelEh2F2PjB/oKp2XMbp96vZzohVVpCMjtNk0mOwo7QDnY sH06/gmeu2NBiGOKFru4y3wbepwIit0hBbG/jjoy4YcLF3ZOWZkVy+Kh6XxnpZcy0HN7Xk RFc+ncXJP8OuVChYzp9/1h9xowBNibT9vREOhqtW4vXOjR2VxAC/D6f1TsMiPg== Received: from matt by naz with local (Exim 4.96) (envelope-from ) id 1orOu0-000ECn-1u for control@debbugs.gnu.org; Sat, 05 Nov 2022 12:32:24 -0700 To: control@debbugs.gnu.org From: Matt Armstrong Subject: control message for bug #59029 Message-Id: Date: Sat, 05 Nov 2022 12:32:24 -0700 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) tags 59029 + patch quit From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 05 16:39:16 2022 Received: (at 59029) by debbugs.gnu.org; 5 Nov 2022 20:39:16 +0000 Received: from localhost ([127.0.0.1]:58164 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1orPwi-0001RN-Je for submit@debbugs.gnu.org; Sat, 05 Nov 2022 16:39:16 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:58747) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1orPwe-0001R8-MV for 59029@debbugs.gnu.org; Sat, 05 Nov 2022 16:39:15 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id E83038037F; Sat, 5 Nov 2022 16:39:05 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 1C83C80091; Sat, 5 Nov 2022 16:39:00 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1667680740; bh=xSrDWqJ+ew1z1YBPHhkSUCGS5v1JmZeVqxLy32VVcAw=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=e9upI0m3Htdrw4O08eS6oIhkt3nbYInYFLLK+osM4ofQ3m/v6C6meETQgGV8v9HK1 WUqYqIacFc1ick0hJoLUZ6aR31yhTWAnx9Xdcvh041WVpM+rV7vWHBhT1JWJPpZBOA JaWL9YlPuEXF78pkuHbvqOvnZrRpvm9GvbU4b8M3g9Mn9k/yG0NOFya4cYXSZbdwsX Ef2bWNje6svwi/aktl6nhDxnpgUIOuk4vJDWj6tfKy3TQCiXWIaCK+WBqY1fJLHtH0 YhsOlJuzEjOZXS5ydvFzApfSmX/6zpO9no8JGSiYM7WrCqOUNlVbzn239qwWn/SNeC HId1aZvnoazuA== Received: from pastel (unknown [104.247.241.157]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id C1E67120A73; Sat, 5 Nov 2022 16:38:59 -0400 (EDT) From: Stefan Monnier To: Matt Armstrong Subject: Re: bug#59029: 29.0.50; noverlay: pdumper.c: dump_interval_node recursion has no base case In-Reply-To: <87leoqwc4o.fsf@rfc20.org> (Matt Armstrong's message of "Fri, 04 Nov 2022 16:09:11 -0700") Message-ID: References: <87leoqwc4o.fsf@rfc20.org> Date: Sat, 05 Nov 2022 16:38:47 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59029 Cc: 59029@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > See the code for dump_interval_node() in pdumper.c below. This code is indeed incorrect. Currently we can only dump deleted overlays (the dump of a buffer fails if there are overlays in it), so the code has only been tested for overlays that have been deleted (and whose parent/left/right fields are NULL, which is not actually guaranteed for deleted overlays: it's the case if the overlay has been `delete-overlay`ed, but not if it was deleted by `kill-buffer`, IIRC). And I fully agree with Gerd it should say "itree" rather than "interval". Stefan From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 06 01:21:21 2022 Received: (at 59029) by debbugs.gnu.org; 6 Nov 2022 05:21:21 +0000 Received: from localhost ([127.0.0.1]:58535 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1orY5x-00068k-0f for submit@debbugs.gnu.org; Sun, 06 Nov 2022 01:21:21 -0400 Received: from mail-ej1-f54.google.com ([209.85.218.54]:37589) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1orY5v-00068X-Fv for 59029@debbugs.gnu.org; Sun, 06 Nov 2022 01:21:19 -0400 Received: by mail-ej1-f54.google.com with SMTP id ud5so22604526ejc.4 for <59029@debbugs.gnu.org>; Sat, 05 Nov 2022 22:21:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=uzntPk5L4aKvG3wJspCGjlwVluWFjl7jUjKLVKRNG1g=; b=LD7ca+FDvVjawYvJo6Jwb6+sJFtPzlS7rGPQSGvsTVdeihmxvNQtLDbun74Wq50c5/ 1fzCHFzz7jGEOubtSLiCxNVG8rdEhOItnWWXzHJOlddBUv2UvVg/KKeUffKfpZ3N0SBr qYrt/J3SmvlTbNt6riyH95S58cF7U/ORoDFh0PZWJJxFeXPXMdoUptAwMdXd+yUy6TrD V6RF2loTfatT/aIosEvLZpSnJ5dmckFuVhu9qziukzDOJIcU8LkqZH8zbtfaNzSUSICR r4iqg+CJnKjret+vfKrQO9WiP0YkD4O2e9tuCsbQRVH9QWqyA7mnGIGB+SvgfzV5ALSu +QQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uzntPk5L4aKvG3wJspCGjlwVluWFjl7jUjKLVKRNG1g=; b=70lIcVbrVnS22yvHMebodVOW7r/kRE8ntTd8YkGK/pYSKpa1MFe215P4r/vtltbqI3 hCSSZdgEpoKYgufBrzyHk8xVJnOq/RA8qfTD/jtSRSmxFeONFnAhk6w8+gyoDKTiyEIW 3dskg+azi/HumpGI7Ab0FWovnKi7FMS5na2JM4ADjttbtYjWfCy2CrL3dPpXJZiUa//V K9hWW4iI6eYCE4ly7IZ3WYpo6ic56nw7O6NSZ2oMghB7ZSjS+TaRUngV0BFuewP5CsRe 50743uwedh4hT3GfDs87vsva3tbZ+wEwQC2IMecX3sP1j0wVGOQjVmWxXnH5C3JVTGG/ VQUQ== X-Gm-Message-State: ANoB5pmo4uGio0yVerZzNgGfwY1ueg2ZuTFXAEDCaF/lFw3flqwxk0hm zKtmJdzCXTkhP4+SY36/VnWkr5RKdvXY6A== X-Google-Smtp-Source: AA0mqf7nvdSkIEfsQgSlFgN6Dpifd5azWb+JYeJPT6AkF1BZYWxDyFyrxBt7qPstONSo80LTbpxfCA== X-Received: by 2002:a17:907:7faa:b0:7ad:e8e4:6ac7 with SMTP id qk42-20020a1709077faa00b007ade8e46ac7mr2648520ejc.21.1667712073977; Sat, 05 Nov 2022 22:21:13 -0700 (PDT) Received: from [192.168.178.21] (pd9e3617e.dip0.t-ipconnect.de. [217.227.97.126]) by smtp.gmail.com with ESMTPSA id 26-20020a170906319a00b0073d753759fasm1727860ejy.172.2022.11.05.22.21.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 05 Nov 2022 22:21:13 -0700 (PDT) Message-ID: <40961e6d-801a-ebeb-c164-76743ac80472@gmail.com> Date: Sun, 6 Nov 2022 06:21:12 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: bug#59029: 29.0.50; noverlay: pdumper.c: dump_interval_node recursion has no base case Content-Language: en-US To: Matt Armstrong References: <87leoqwc4o.fsf@rfc20.org> <87cza1w9wm.fsf@rfc20.org> From: =?UTF-8?Q?Gerd_M=c3=b6llmann?= In-Reply-To: <87cza1w9wm.fsf@rfc20.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -1.8 (-) X-Debbugs-Envelope-To: 59029 Cc: 59029@debbugs.gnu.org, stefan monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.8 (--) On 05.11.22 19:09, Matt Armstrong wrote: > Gerd Möllmann writes: > >> Yes, I think you are right. >> >> Could we also rename dump_interval_node to dump_itree_node? There is >> another function dump_interval_tree for text properties, which is a bit >> confusing. > > Attached renames the function and tags two related FIXMEs with this bug > number. The root issue is that pdumping buffers with overlays is not > implemented. > LGTM. From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 08 10:59:58 2022 Received: (at 59029) by debbugs.gnu.org; 8 Nov 2022 15:59:58 +0000 Received: from localhost ([127.0.0.1]:38028 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osR14-0004Re-EG for submit@debbugs.gnu.org; Tue, 08 Nov 2022 10:59:58 -0500 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:47395) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osR11-0004RP-M3 for 59029@debbugs.gnu.org; Tue, 08 Nov 2022 10:59:56 -0500 Received: (Authenticated sender: matt@rfc20.org) by mail.gandi.net (Postfix) with ESMTPSA id 9C48020011; Tue, 8 Nov 2022 15:59:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rfc20.org; s=gm1; t=1667923189; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0LH7OQwZyByiMUDprHXxkNGtDz2WEdynVi8xxzAch/8=; b=lhibipGqkOabcrCzJWFtNy4IQCYp4zHiOC5A9IeWZXO6/UilpfrWTQeDrcqiCFYxnhIrW2 XLeuoc+d2FKb/pTZJPtY5BE1az4gxSsI+fStmdektfMPY6sy1Emh76B6WWhQYHVYx3/gtS Ak/loqR8T/P/W8YlOJnQEGWuTpB5AqL1OWXPCgpfE5eHPIb3LA0vxc7RAOps1efG/tZPQQ n0+Mvk3TOk6BlC6cVGdI6cU3tN9/EmLTXZGvCm0e4BYd2ZEGT5YS98fWWWKoTB6dpy5fKy HrqmhQUfzpN/dB6RLOEhuXvYrVohYSXR8AaxnDaqqOSSUjyo0f7Qy/u9+zyoYA== Received: from matt by naz with local (Exim 4.96) (envelope-from ) id 1osR0r-001Ah2-2i; Tue, 08 Nov 2022 07:59:45 -0800 From: Matt Armstrong To: Stefan Monnier Subject: Re: bug#59029: Dumping Emacs crashes when buffers have overlays In-Reply-To: (Stefan Monnier's message of "Sat, 05 Nov 2022 16:38:47 -0400") References: <87leoqwc4o.fsf@rfc20.org> Date: Tue, 08 Nov 2022 07:59:45 -0800 Message-ID: <87k045mo7i.fsf_-_@rfc20.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 59029 Cc: 59029@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Stefan Monnier writes: >> See the code for dump_interval_node() in pdumper.c below. > > This code is indeed incorrect. I have time to work on this, but I don't have a clear path and would like to hear opinions. I see two options. a) Drop support for dumping overlays in buffers, as if `delete-all-overlays' were called for all buffers before dumping. Fix involves relaxing the abort() calls to merely print warnings. b) Restore support, and test it. For (b) I'm not keen on wiring up a single-purpose test under test/* somewhere just to test pdumping with overlays. How about hooking in to loadup.el to populate a dummy buffer with overlays before dumping? Emacs could delete it early, so it wouldn't be gone before users noticed. Or, are there other alternatives I'm missing? From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 08 11:59:50 2022 Received: (at 59029) by debbugs.gnu.org; 8 Nov 2022 16:59:50 +0000 Received: from localhost ([127.0.0.1]:38082 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osRx0-0005t4-1L for submit@debbugs.gnu.org; Tue, 08 Nov 2022 11:59:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51668) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osRwy-0005sq-2u for 59029@debbugs.gnu.org; Tue, 08 Nov 2022 11:59:48 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1osRws-0007fh-8N; Tue, 08 Nov 2022 11:59:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=LzdYoYfLM/MdgTFWU2Zr0SfGdCiYxtjXii1ONVmjPzQ=; b=csSR/TPWJ9X3 FmRUi6eeVWmkOdmjhieuIbioBK1wwehNgVYn9sNR5+lAlHVhGXQA5JiAxgoteTv9UtP2T3BI9jL+5 gLt2SVMjW44xb7LgO9bysVdh8pu090gc+uwcbcXJW8+2qrZHO8N6nmqrEjWR5lHiLKjoR/5IHPGiy VBWe3r7GKZi2vwbBirgtT1s5eF4LtHrIgsgSpsgQ7en6HlFcIi8zuC7YUo+1cYvPxteuj8cbU6zK3 7ni0HXTijzA0RY1UwFdmcZ5oV+HT4CUpEFATctr/p01438aqUvpDNftrnUDye03AfAX2yuJMCojjk 6AFZJzCWm5u1heiwHOju1Q==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1osRwr-0003DC-M6; Tue, 08 Nov 2022 11:59:42 -0500 Date: Tue, 08 Nov 2022 18:59:29 +0200 Message-Id: <83cz9xxtzi.fsf@gnu.org> From: Eli Zaretskii To: Matt Armstrong In-Reply-To: <87k045mo7i.fsf_-_@rfc20.org> (message from Matt Armstrong on Tue, 08 Nov 2022 07:59:45 -0800) Subject: Re: bug#59029: Dumping Emacs crashes when buffers have overlays References: <87leoqwc4o.fsf@rfc20.org> <87k045mo7i.fsf_-_@rfc20.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59029 Cc: 59029@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Cc: 59029@debbugs.gnu.org > From: Matt Armstrong > Date: Tue, 08 Nov 2022 07:59:45 -0800 > > a) Drop support for dumping overlays in buffers, as if > `delete-all-overlays' were called for all buffers before dumping. Fix > involves relaxing the abort() calls to merely print warnings. > > b) Restore support, and test it. a) could be a short-term band-aid, but if we want ever to support re-dumping, b) is a must. > For (b) I'm not keen on wiring up a single-purpose test under test/* > somewhere just to test pdumping with overlays. How about hooking in to > loadup.el to populate a dummy buffer with overlays before dumping? For testing purposes, you could perhaps use eval-after-load to do something after loading loadup.el? From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 08 12:21:38 2022 Received: (at 59029) by debbugs.gnu.org; 8 Nov 2022 17:21:38 +0000 Received: from localhost ([127.0.0.1]:38107 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osSI6-0006Qu-FN for submit@debbugs.gnu.org; Tue, 08 Nov 2022 12:21:38 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:55267) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osSI5-0006Qh-Cl for 59029@debbugs.gnu.org; Tue, 08 Nov 2022 12:21:37 -0500 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 7836310012E; Tue, 8 Nov 2022 12:21:31 -0500 (EST) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 990B11000DA; Tue, 8 Nov 2022 12:21:25 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1667928085; bh=Pfe1F1Z/FLqmKWdMrzNMwH0eBAVcEaIfj6Mr03oeWQE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=YCC6byA5TixXdZjnw+JbL/cCBShKhFqLbu7o6UcM5pbHFZgBxBOlCEykNDkre8YdZ Tn4a8Onp6SxE31dbJdfUM3W67K3QjfaIF4NUx4LwnZisKhDfo/pV3ljSs82fW7SsQ/ sozHORDdUNZpI8w3qGMKCk/EslfbnZ3kxy5HLeih20DUyuBk0DWZ9srMbPmZ3b3r7n t5XWE8LlMqU6iSepIGz/vaLK4MZBGUUSggvPwKH+RN19TReW9KracDdyJYGbrWHOH9 fO/YBJsKleNZ173tRabseX7LiD2F2QFlyAYeO3zNYUkMNotGe3YgrGsg4Eu1Oh93hp 6taBJ7EvhtO+g== Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 856981202EE; Tue, 8 Nov 2022 12:21:25 -0500 (EST) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#59029: Dumping Emacs crashes when buffers have overlays In-Reply-To: <83cz9xxtzi.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 08 Nov 2022 18:59:29 +0200") Message-ID: References: <87leoqwc4o.fsf@rfc20.org> <87k045mo7i.fsf_-_@rfc20.org> <83cz9xxtzi.fsf@gnu.org> Date: Tue, 08 Nov 2022 12:21:24 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.100 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 59029 Cc: Matt Armstrong , 59029@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> a) Drop support for dumping overlays in buffers, as if >> `delete-all-overlays' were called for all buffers before dumping. Fix >> involves relaxing the abort() calls to merely print warnings. >> >> b) Restore support, and test it. > > a) could be a short-term band-aid, but if we want ever to support > re-dumping, b) is a must. FWIW, I suspect that the vast majority of redumping uses will/would be to include more preloaded ELisp code rather than to include pre-populated buffers, so it's quite likely that it would work just fine without that extra support for dumping overlays-in-buffers. But I agree that (b) is a must, because I find it sad if we can't get the pdumping code working. >> For (b) I'm not keen on wiring up a single-purpose test under test/* >> somewhere just to test pdumping with overlays. How about hooking in to >> loadup.el to populate a dummy buffer with overlays before dumping? > For testing purposes, you could perhaps use eval-after-load to do > something after loading loadup.el? IMO, we should have a proper separate pdump test, instead. Stefan From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 09 15:04:16 2022 Received: (at 59029) by debbugs.gnu.org; 9 Nov 2022 20:04:16 +0000 Received: from localhost ([127.0.0.1]:40986 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osrJ1-0000ql-KI for submit@debbugs.gnu.org; Wed, 09 Nov 2022 15:04:16 -0500 Received: from relay10.mail.gandi.net ([217.70.178.230]:47151) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osrIy-0000qW-Ts for 59029@debbugs.gnu.org; Wed, 09 Nov 2022 15:04:13 -0500 Received: (Authenticated sender: matt@rfc20.org) by mail.gandi.net (Postfix) with ESMTPSA id 33552240004; Wed, 9 Nov 2022 20:04:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rfc20.org; s=gm1; t=1668024247; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zEo8XHopmvSnfjQ+OIzTHPidr8dRM9LxY8LZriDmW0o=; b=EnLzdnIFHmaOINLBs1u3ULnZdpnMSfqm50lNxxlPKUVYUhbuaPDNCP8U1hFfPC5pwTuwZ1 sb8nXFfBO0ybuFDxr5stoZpYoXhhR9zhB7Xm2vYTWH8ztOh5PnzeGfxHR+zxb6Ma/p+dJ3 qBbq/PkpnaY5xyqZ25ID3AtzurUQz4lE7QpvBbnPqlmVLU3kxPAy2SoxqBPPjdD1BtNoy1 5YDnDQxloDiqclpiahxgSd7FkPUBH5UDl7oN9+dzQ11n74r8I7xqas/v2iOAWyXqIQRjIz Jf0Rq0cbUv3Sz/B3KXPvQ1S9Xm3tDphUIez9s0FBvI8C5l9Tw1y49uP9qyENYA== Received: from matt by naz with local (Exim 4.96) (envelope-from ) id 1osrIp-002Bl0-1D; Wed, 09 Nov 2022 12:04:03 -0800 From: Matt Armstrong To: Stefan Monnier , Eli Zaretskii Subject: Re: bug#59029: Dumping Emacs crashes when buffers have overlays In-Reply-To: References: <87leoqwc4o.fsf@rfc20.org> <87k045mo7i.fsf_-_@rfc20.org> <83cz9xxtzi.fsf@gnu.org> Date: Wed, 09 Nov 2022 12:04:03 -0800 Message-ID: <87y1sjlwss.fsf@rfc20.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 59029 Cc: 59029@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain Stefan Monnier writes: > IMO, we should have a proper separate pdump test, instead. I tend to agree with Stefan about the relatively low importance of supporting overlays owned by buffers in the dump. I have deferred that work, though the tests I have added will be useful if someone wants to take it up in the future. See attached patch, which: a) Adds a test that exercises portable dumping from a batch mode subprocess, using the Emacs executable hosting the test as a basis. b) Performs the dump while a buffer with overlays is live in the subprocess. c) Verifies the dump by running a second subprocess and checking how many overlays are in the buffer that had overlays. The test took most of the time. I'm quite open to suggestions there; my elisp knowledge is novice level. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Fix-portable-dumping-when-buffers-have-overlays.patch >From eee0419f7d702e67671197a5c65c83b77af3c489 Mon Sep 17 00:00:00 2001 From: Matt Armstrong Date: Tue, 8 Nov 2022 17:10:02 -0800 Subject: [PATCH] Fix portable dumping when buffers have overlays. See bug#59029. While it is possible to fully support overlays in dump files, the code involved is non-trivial and we have decided to defer this work. Instead, a buffer's overlays are dumped only if they are reachable from something other than their buffer, and as if they had been deleted. * src/itree.c (itree_node_init): Initialize fields in declared order. Zero-initialize unspecified fields. * src/pdumper.c (dump_itree_node): Always dump as if the node had been deleted from its buffer. Renamed from dump_interval_node. (dump_buffer): Never dump a buffer's overlays. * test/src/pdumper-tests.el: New test to exercise the above. --- src/itree.c | 15 +++-- src/pdumper.c | 50 ++++---------- test/src/pdumper-tests.el | 133 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 152 insertions(+), 46 deletions(-) create mode 100644 test/src/pdumper-tests.el diff --git a/src/itree.c b/src/itree.c index 989173db4e..fecad886e3 100644 --- a/src/itree.c +++ b/src/itree.c @@ -534,14 +534,15 @@ itree_node_init (struct itree_node *node, bool front_advance, bool rear_advance, Lisp_Object data) { - node->parent = NULL; - node->left = NULL; - node->right = NULL; - node->begin = -1; - node->end = -1; - node->front_advance = front_advance; - node->rear_advance = rear_advance; + node->begin = 0; + node->end = 0; + node->limit = 0; + node->offset = 0; + node->otick = 0; node->data = data; + node->red = 0; + node->rear_advance = rear_advance; + node->front_advance = front_advance; } /* Return NODE's begin value, computing it if necessary. */ diff --git a/src/pdumper.c b/src/pdumper.c index 0a5d96dbb7..652dfc2e71 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -2134,46 +2134,20 @@ dump_marker (struct dump_context *ctx, const struct Lisp_Marker *marker) } static dump_off -dump_interval_node (struct dump_context *ctx, struct itree_node *node, - dump_off parent_offset) +dump_itree_node (struct dump_context *ctx, struct itree_node *node, + dump_off parent_offset) { #if CHECK_STRUCTS && !defined (HASH_itree_node_50DE304F13) # error "itree_node changed. See CHECK_STRUCTS comment in config.h." #endif + /* Dumping of a buffer's overlays is not implemented. Overlays are + dumped as if they had been deleted. See bug#59029. */ struct itree_node out; dump_object_start (ctx, &out, sizeof (out)); - if (node->parent) - dump_field_fixup_later (ctx, &out, node, &node->parent); - if (node->left) - dump_field_fixup_later (ctx, &out, node, &node->parent); - if (node->right) - dump_field_fixup_later (ctx, &out, node, &node->parent); - DUMP_FIELD_COPY (&out, node, begin); - DUMP_FIELD_COPY (&out, node, end); - DUMP_FIELD_COPY (&out, node, limit); - DUMP_FIELD_COPY (&out, node, offset); - DUMP_FIELD_COPY (&out, node, otick); + itree_node_init (&out, node->front_advance, node->rear_advance, + node->data); dump_field_lv (ctx, &out, node, &node->data, WEIGHT_STRONG); - DUMP_FIELD_COPY (&out, node, red); - DUMP_FIELD_COPY (&out, node, rear_advance); - DUMP_FIELD_COPY (&out, node, front_advance); - dump_off offset = dump_object_finish (ctx, &out, sizeof (out)); - if (node->parent) - dump_remember_fixup_ptr_raw - (ctx, - offset + dump_offsetof (struct itree_node, parent), - dump_interval_node (ctx, node->parent, offset)); - if (node->left) - dump_remember_fixup_ptr_raw - (ctx, - offset + dump_offsetof (struct itree_node, left), - dump_interval_node (ctx, node->left, offset)); - if (node->right) - dump_remember_fixup_ptr_raw - (ctx, - offset + dump_offsetof (struct itree_node, right), - dump_interval_node (ctx, node->right, offset)); - return offset; + return dump_object_finish (ctx, &out, sizeof (out)); } static dump_off @@ -2189,7 +2163,7 @@ dump_overlay (struct dump_context *ctx, const struct Lisp_Overlay *overlay) dump_remember_fixup_ptr_raw (ctx, offset + dump_offsetof (struct Lisp_Overlay, interval), - dump_interval_node (ctx, overlay->interval, offset)); + dump_itree_node (ctx, overlay->interval, offset)); return offset; } @@ -2863,11 +2837,9 @@ dump_buffer (struct dump_context *ctx, const struct buffer *in_buffer) DUMP_FIELD_COPY (out, buffer, inhibit_buffer_hooks); DUMP_FIELD_COPY (out, buffer, long_line_optimizations_p); - if (buffer->overlays && buffer->overlays->root != NULL) - /* We haven't implemented the code to dump overlays. */ - emacs_abort (); - else - out->overlays = NULL; + /* Dumping of a buffer's overlays is not implemented. See + bug#59029. */ + out->overlays = NULL; dump_field_lv (ctx, out, buffer, &buffer->undo_list_, WEIGHT_STRONG); diff --git a/test/src/pdumper-tests.el b/test/src/pdumper-tests.el new file mode 100644 index 0000000000..18b7a7afb5 --- /dev/null +++ b/test/src/pdumper-tests.el @@ -0,0 +1,133 @@ +;;; pdumper-tests.el --- pdumper tests -*- lexical-binding: t; -*- + +;; Copyright (C) 2022 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Code: + +(require 'ert-x) + +(defun pdumper-tests--readable-arg (form) + (let ((print-gensym t) + (print-circle t) + (print-length nil) + (print-level nil) + (print-escape-control-characters t) + (print-escape-newlines t) + (print-escape-multibyte t) + (print-escape-nonascii t)) + (if-let ((str (readablep form))) + str + (error "unreadable form %S" form)))) + +(defun pdumper-tests--eval-arg (form) + (concat "--eval=" (pdumper-tests--readable-arg form))) + +(defun pdumper-tests--batch-eval-command (emacs form) + `(,@emacs "--quick" "--batch" + ,(pdumper-tests--eval-arg form))) + +(defun pdumper-tests--emacs-binary () + (expand-file-name invocation-name invocation-directory)) + +(defun pdumper-tests--check-output (dir command) + "Run COMMAND as a synchronous subprocess. + +The process' current directory is set to DIR. Fail the test if +the process exits with a non-zero status. Otherwise, return its +output as a string." + (with-temp-buffer + (setq default-directory dir) + (let ((result (apply #'call-process + (car command) + nil t nil + (cdr command)))) + (unless (equal 0 result) + (ert-info ((format "In directory %S" dir)) + (ert-info ((format "Ran command %S" command)) + (ert-info ((format "With output %S" (buffer-string))) + (should (equal 0 result))))))) + (buffer-string))) + +(defun pdumper-tests--batch-redump (loadup-form redumped-form) + "Redump the current Emacs binary and verify it works. + +First, run the current Emacs binary in a synchronous subprocess. +Evaluate LOADUP-FORM in it, then dump it with +`dump-emacs-portable'. + +Second, run the current Emacs binary in a second subprocess, this +time with \"--dump-file\" set to the dump file just created. +Evaluate REDUMPED-FORM in this second process. + +Returns the output of the second run as a string." + (ert-with-temp-directory tmpdir + (let* ((dump-file (concat tmpdir "redump.pdmp")) + (loadup-file (concat tmpdir "redump.el")) + (emacs-binary (pdumper-tests--emacs-binary)) + (dump-command (pdumper-tests--batch-eval-command + (list emacs-binary) + `(progn + (load ,loadup-file) + (dump-emacs-portable ,dump-file))))) + (with-temp-file loadup-file + (insert (prin1-to-string loadup-form))) + (should (string-search "Dump complete" + (pdumper-tests--check-output + tmpdir dump-command))) + (let* ((redumped-emacs-command + (list emacs-binary + (concat "--dump-file=" dump-file))) + (redumped-emacs-validate + (pdumper-tests--batch-eval-command + redumped-emacs-command + redumped-form))) + (pdumper-tests--check-output + tmpdir + redumped-emacs-validate))))) + +(ert-deftest pdumper-tests-redump-overlays () + "Test portable dumping when overlays are in a buffer. + +In an Emacs subprocess create a buffer with some overlays, then +dump it. Run with the new dump file and verify the buffer exists +and is in the correct state." + (skip-unless (fboundp 'pdumper-stats)) + (let* ((overlay-buffer " *redump-overlays*") + (phrase "Lorem ipsum dolor sit amet, consectetur...") + (redump-output + (pdumper-tests--batch-redump + `(with-current-buffer (get-buffer-create ,overlay-buffer) + (insert ,phrase) + (dotimes (i 8) + (make-overlay (+ (point-min) i) + (+ (point-min) (+ i 10))))) + `(with-current-buffer (get-buffer-create ,overlay-buffer) + (unless (equal ,phrase (buffer-string)) + (error "buffer text not as expected")) + (let ((overlays (overlays-in (point-min) (point-max)))) + (princ (format "Redumped overlay count: <%d>" + (length overlays)))))))) + ;; Dumping of a buffer's overlays is not implemented. Overlays + ;; are dumped as if they had been deleted, so the redumped Emacs + ;; should have zero overlays in the *redump-overlays* buffer. See + ;; bug#59029. */ + (should (string-search "Redumped overlay count: <0>" + redump-output)))) + +(provide 'pdumper-tests) +;;; pdumper-tests.el ends here -- 2.35.1 --=-=-=--