From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#30931: abort() due to CHECK_ALLOCATED_AND_LIVE failure during GC Date: Fri, 30 Mar 2018 14:29:07 -0700 Organization: UCLA Computer Science Department Message-ID: <892e5c68-35a3-3a24-dd8c-a6badf028275@cs.ucla.edu> References: <0eb14aa5-8110-8336-5d3d-fac46ccc23f3@zoho.com> <9829542a-15bb-6a83-20b0-2fd4dc42b8d4@cs.ucla.edu> <87woxtpvrv.fsf@gmail.com> <87tvsxp9si.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------BB878D2C4DA6C33FC3EBF803" X-Trace: blaine.gmane.org 1522445294 3612 195.159.176.226 (30 Mar 2018 21:28:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 30 Mar 2018 21:28:14 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 Cc: 30931-done@debbugs.gnu.org, =?UTF-8?Q?Micha=C5=82?= Kondraciuk To: Noam Postavsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Mar 30 23:28:09 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f21ZA-0000md-1Z for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Mar 2018 23:28:08 +0200 Original-Received: from localhost ([::1]:44248 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f21bC-0006U8-3k for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Mar 2018 17:30:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37978) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f21b5-0006TP-76 for bug-gnu-emacs@gnu.org; Fri, 30 Mar 2018 17:30:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f21b1-0007c2-6v for bug-gnu-emacs@gnu.org; Fri, 30 Mar 2018 17:30:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52583) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f21b1-0007be-2Y for bug-gnu-emacs@gnu.org; Fri, 30 Mar 2018 17:30:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1f21b0-0003Uc-LN for bug-gnu-emacs@gnu.org; Fri, 30 Mar 2018 17:30:02 -0400 Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Fri, 30 Mar 2018 21:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 30931 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Mail-Followup-To: 30931@debbugs.gnu.org, eggert@cs.ucla.edu, k.michal@zoho.com Original-Received: via spool by 30931-done@debbugs.gnu.org id=D30931.152244535813351 (code D ref 30931); Fri, 30 Mar 2018 21:30:02 +0000 Original-Received: (at 30931-done) by debbugs.gnu.org; 30 Mar 2018 21:29:18 +0000 Original-Received: from localhost ([127.0.0.1]:60478 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f21aH-0003TG-Ql for submit@debbugs.gnu.org; Fri, 30 Mar 2018 17:29:18 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:38716) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f21aF-0003T2-KT for 30931-done@debbugs.gnu.org; Fri, 30 Mar 2018 17:29:16 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 4CC05161701; Fri, 30 Mar 2018 14:29:09 -0700 (PDT) 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 UtKVTMxDK5TC; Fri, 30 Mar 2018 14:29:08 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 4E917161702; Fri, 30 Mar 2018 14:29:08 -0700 (PDT) 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 zVBa2hkFMUn2; Fri, 30 Mar 2018 14:29:08 -0700 (PDT) Original-Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 2CA33161701; Fri, 30 Mar 2018 14:29:08 -0700 (PDT) In-Reply-To: <87tvsxp9si.fsf@gmail.com> 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: 208.118.235.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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:144751 Archived-At: This is a multi-part message in MIME format. --------------BB878D2C4DA6C33FC3EBF803 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Thanks, I installed that along with the attached minor refactoring so that the bugfix is in just one place. Closing the bug. I assume that this fix should not be backported into the emacs-26 branch, as the bug is in Emacs 25. --------------BB878D2C4DA6C33FC3EBF803 Content-Type: text/x-patch; name="0001-Centralize-Bug-30931-fix.patch" Content-Disposition: attachment; filename="0001-Centralize-Bug-30931-fix.patch" Content-Transfer-Encoding: quoted-printable >From 529377bc392039dc253c8b5f2410964c8581ffd9 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 30 Mar 2018 14:23:55 -0700 Subject: [PATCH] Centralize Bug#30931 fix * src/marker.c (detach_marker): New function. * src/editfns.c (save_restriction_restore): * src/insdel.c (signal_before_change): Use it. --- src/editfns.c | 9 +++------ src/insdel.c | 7 ++----- src/lisp.h | 3 ++- src/marker.c | 13 +++++++++++-- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/editfns.c b/src/editfns.c index 84de679273..608304c09a 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -3899,12 +3899,9 @@ save_restriction_restore (Lisp_Object data) =20 buf->clip_changed =3D 1; /* Remember that the narrowing changed. */ } - /* This isn=E2=80=99t needed anymore, so don=E2=80=99t wait for GC= . Do not call - free_marker on XCAR (data) or XCDR (data), though, since - record_marker_adjustments may have put them on the buffer=E2=80= =99s - undo list (Bug#30931). Just detach them instead. */ - Fset_marker (XCAR (data), Qnil, Qnil); - Fset_marker (XCDR (data), Qnil, Qnil); + /* Detach the markers, and free the cons instead of waiting for GC= . */ + detach_marker (XCAR (data)); + detach_marker (XCDR (data)); free_cons (XCONS (data)); } else diff --git a/src/insdel.c b/src/insdel.c index 697395c507..173c243834 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -2148,13 +2148,10 @@ signal_before_change (ptrdiff_t start_int, ptrdif= f_t end_int, FETCH_START, FETCH_END, Qnil); } =20 - /* Detach the markers now that we're done with them. Don't directly - free them, since the change functions could have caused them to - be inserted into the undo list (Bug#30931). */ if (! NILP (start_marker)) - Fset_marker (start_marker, Qnil, Qnil); + detach_marker (start_marker); if (! NILP (end_marker)) - Fset_marker (end_marker, Qnil, Qnil); + detach_marker (end_marker); RESTORE_VALUE; =20 unbind_to (count, Qnil); diff --git a/src/lisp.h b/src/lisp.h index f471b21658..c931d9c8f0 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4104,7 +4104,8 @@ extern ptrdiff_t marker_byte_position (Lisp_Object)= ; extern void clear_charpos_cache (struct buffer *); extern ptrdiff_t buf_charpos_to_bytepos (struct buffer *, ptrdiff_t); extern ptrdiff_t buf_bytepos_to_charpos (struct buffer *, ptrdiff_t); -extern void unchain_marker (struct Lisp_Marker *marker); +extern void detach_marker (Lisp_Object); +extern void unchain_marker (struct Lisp_Marker *); extern Lisp_Object set_marker_restricted (Lisp_Object, Lisp_Object, Lisp= _Object); extern Lisp_Object set_marker_both (Lisp_Object, Lisp_Object, ptrdiff_t,= ptrdiff_t); extern Lisp_Object set_marker_restricted_both (Lisp_Object, Lisp_Object, diff --git a/src/marker.c b/src/marker.c index 2a45ae636e..2d5b05cc2b 100644 --- a/src/marker.c +++ b/src/marker.c @@ -560,7 +560,7 @@ POSITION is nil, makes marker point nowhere so it no = longer slows down editing in any buffer. Returns MARKER. */) (Lisp_Object marker, Lisp_Object position, Lisp_Object buffer) { - return set_marker_internal (marker, position, buffer, 0); + return set_marker_internal (marker, position, buffer, false); } =20 /* Like the above, but won't let the position be outside the visible par= t. */ @@ -569,7 +569,7 @@ Lisp_Object set_marker_restricted (Lisp_Object marker, Lisp_Object position, Lisp_Object buffer) { - return set_marker_internal (marker, position, buffer, 1); + return set_marker_internal (marker, position, buffer, true); } =20 /* Set the position of MARKER, specifying both the @@ -616,6 +616,15 @@ set_marker_restricted_both (Lisp_Object marker, Lisp= _Object buffer, return marker; } =20 +/* Detach a marker so that it no longer points anywhere and no longer + slows down editing. Do not free the marker, though, as a change + function could have inserted it into an undo list (Bug#30931). */ +void +detach_marker (Lisp_Object marker) +{ + Fset_marker (marker, Qnil, Qnil); +} + /* Remove MARKER from the chain of whatever buffer it is in, leaving it points to nowhere. This is called during garbage collection, so we must be careful to ignore and preserve --=20 2.14.3 --------------BB878D2C4DA6C33FC3EBF803--