unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Failing to GC killed buffers considered harmful
@ 2020-03-29 14:23 Eli Zaretskii
  2020-03-29 16:45 ` Stefan Monnier
  2020-03-29 16:46 ` Pip Cet
  0 siblings, 2 replies; 26+ messages in thread
From: Eli Zaretskii @ 2020-03-29 14:23 UTC (permalink / raw)
  To: Pip Cet, Daniel Colascione; +Cc: emacs-devel

This recent change on master:

  commit afaf2f465188ab1f438ff3e021260e7c529b1b9d
  Author:     Pip Cet <pipcet@gmail.com>
  AuthorDate: Sat Mar 14 18:26:33 2020 +0000
  Commit:     Eli Zaretskii <eliz@gnu.org>
  CommitDate: Sun Mar 15 16:35:07 2020 +0200

      Make sure we mark reachable killed buffers during GC

      * src/alloc.c (live_buffer_holding): Add ALL_BUFFERS argument for
      returning killed buffers.
      (mark_maybe_object, mark_maybe_pointer): Use the additional
      argument.  (Bug#39962)

causes us to dump killed buffers in some cases.  Presumably, the call
to GC right before we start pdumping fails to collect a killed buffer,
and it ends up being dumped.  When we restore from emacs.pdump, an
Emacs built with --enable-checking on a platform that uses mmap for
buffer text aborts here:

  #ifdef USE_MMAP_FOR_BUFFERS
    if (dumped_with_unexec_p ())
      {
	...
      }
    else
      {
	struct buffer *b;

	/* Only buffers with allocated buffer text should be present at
	   this point in temacs.  */
	FOR_EACH_BUFFER (b)
	  {
	    eassert (b->text->beg != NULL);  <<<<<<<<<<<<<<<<<
	  }
      }
  #endif /* USE_MMAP_FOR_BUFFERS */

because a killed buffer has its text freed and set to NULL.

We could, of course, remove the assertion, but then we are left with a
dead buffer that will never be GC'ed, AFAIU, because objects that come
from the portable dump are considered constantly marked.

Another idea is to avoid dumping such buffers.  But I couldn't find a
facility for doing that safely; simply having dump_buffer return
causes an assertion violation later:

  #ifdef ENABLE_CHECKING
  static Lisp_Object
  dump_check_overlap_dump_reloc (Lisp_Object lreloc_a,
				 Lisp_Object lreloc_b)
  {
    struct dump_reloc reloc_a = dump_decode_dump_reloc (lreloc_a);
    struct dump_reloc reloc_b = dump_decode_dump_reloc (lreloc_b);
    eassert (dump_reloc_get_offset (reloc_a) < dump_reloc_get_offset (reloc_b));
    return Qnil;
  }
  #endif

Daniel, did I miss some facility to avoid dumping an object safely?

If not, what other solutions could we try, given that whether some
pointer into a buffer ends up on the stack at pdump time is something
we cannot really control?

TIA



^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2020-03-31 21:57 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-29 14:23 Failing to GC killed buffers considered harmful Eli Zaretskii
2020-03-29 16:45 ` Stefan Monnier
2020-03-29 18:54   ` Eli Zaretskii
2020-03-29 19:06     ` Daniel Colascione
2020-03-29 19:24       ` Eli Zaretskii
2020-03-29 16:46 ` Pip Cet
2020-03-29 18:48   ` Eli Zaretskii
2020-03-29 19:07     ` Pip Cet
2020-03-29 19:12       ` Daniel Colascione
2020-03-29 19:25         ` Pip Cet
2020-03-29 19:28           ` Eli Zaretskii
2020-03-30 15:36             ` Pip Cet
2020-03-30 15:53               ` dancol
2020-03-30 17:07             ` Stefan Monnier
2020-03-30 17:02   ` Stefan Monnier
2020-03-30 18:32     ` Stefan Monnier
2020-03-30 18:51       ` Eli Zaretskii
2020-03-30 19:14         ` Daniel Colascione
2020-03-30 19:40         ` Stefan Monnier
2020-03-31 14:07           ` Eli Zaretskii
2020-03-31 14:09       ` Eli Zaretskii
2020-03-31 21:57         ` Stefan Monnier
2020-03-31 14:58       ` Pip Cet
2020-03-31 16:52         ` Stefan Monnier
2020-03-31 18:23           ` Pip Cet
2020-03-31 19:20             ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).