all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@gmail.com>
To: "Michał Kondraciuk" <k.michal@zoho.com>
Cc: 30931 <30931@debbugs.gnu.org>
Subject: bug#30931: 27.0.50; Crash in "Automatic GC"
Date: Fri, 30 Mar 2018 01:39:30 -0400	[thread overview]
Message-ID: <87zi2qp1f1.fsf@gmail.com> (raw)
In-Reply-To: <87605eqwam.fsf@gmail.com> (Noam Postavsky's message of "Thu, 29 Mar 2018 19:47:13 -0400")

Noam Postavsky <npostavs@gmail.com> writes:

> Michał Kondraciuk <k.michal@zoho.com> writes:
>
>> I don't know if it helps, but I was able to reproduce a crash in the
>> same place (mark_object()) with bare Emacs, however only in 27.0.50.
>
> This is very helpful, thank you.

Okay, with this recipe, I was able to put a breakpoint in free_marker
and find where the problem is: save_restriction_save creates markers to
represent the current restriction, record_marker_adjustments (called
from delete-region) puts all buffer markers onto the buffer undo list,
and save_restriction_restore frees the markers created in
save_restriction_save.

    save_restriction_save (void)
    {
    [...]
          beg = build_marker (current_buffer, BEGV, BEGV_BYTE);
          end = build_marker (current_buffer, ZV, ZV_BYTE);

    record_marker_adjustments (ptrdiff_t from, ptrdiff_t to)
    {
    [...]
      for (m = BUF_MARKERS (current_buffer); m; m = m->next)
        {
        [...]
                  XSETMISC (marker, m);
                  bset_undo_list
                    (current_buffer,
                     Fcons (Fcons (marker, make_number (adjustment)),
                            BVAR (current_buffer, undo_list)));

    save_restriction_restore (Lisp_Object data)
    {
    [...]
          /* These aren't needed anymore, so don't wait for GC.  */
          free_marker (XCAR (data));
          free_marker (XCDR (data));

So the following is enough to trigger the bug:

  (with-temp-buffer
    (insert "1234567890")
    (setq buffer-undo-list nil)
    (narrow-to-region 2 5)
    (save-restriction
      (widen)
      (delete-region 1 6))
    (princ (format "%S" buffer-undo-list) #'external-debugging-output)
    (type-of (car (nth 1 buffer-undo-list))))

Surprisingly, printing works on a Lisp_Misc_Free object, so this prints

    (("12345" . 1) (#<misc free cell> . -1) (#<misc free cell> . 1))

before aborting in Ftype_of.  Calling garbage-collect instead of type-of
also aborts.  Calling neither seems to be okay, since in that case the
Lisp_Misc_Free objects somehow turn into #<marker in no buffer>.

For solving this, I guess the easiest would be to have
save_restriction_restore do (set-marker m nil) instead of free_marker.
Might make more sense to avoid putting those markers onto the undo list
in the first place though.





  reply	other threads:[~2018-03-30  5:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-24 20:30 bug#30931: 27.0.50; Crash in "Automatic GC" Michał Kondraciuk
2018-03-25  2:33 ` Eli Zaretskii
2018-03-28 21:02   ` Michał Kondraciuk
2018-03-29 23:47     ` Noam Postavsky
2018-03-30  5:39       ` Noam Postavsky [this message]
2018-03-30  8:16         ` Eli Zaretskii
2018-03-29 15:52   ` Michał Kondraciuk
2018-03-30  6:19 ` bug#30931: abort() due to CHECK_ALLOCATED_AND_LIVE failure during GC Paul Eggert
2018-03-30 12:56   ` Noam Postavsky
2018-03-30 16:23     ` Paul Eggert
2018-03-30 20:50       ` Noam Postavsky
2018-03-30 21:29         ` Paul Eggert
2018-03-31  7:42           ` Eli Zaretskii
2018-04-19 23:42 ` bug#30931: 27.0.50; Crash in "Automatic GC" Noam Postavsky
     [not found] <4d245b9b-16be-954e-f98c-c99796e40431@zoho.com>
2018-03-25  9:46 ` Michał Kondraciuk
2018-03-26 12:45   ` Noam Postavsky
2018-03-26 14:20     ` Noam Postavsky
2018-03-26 14:57       ` Michał Kondraciuk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zi2qp1f1.fsf@gmail.com \
    --to=npostavs@gmail.com \
    --cc=30931@debbugs.gnu.org \
    --cc=k.michal@zoho.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.