all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Pip Cet <pipcet@gmail.com>
To: emacs-devel@gnu.org, Paul Eggert <eggert@cs.ucla.edu>
Cc: emacs-diffs@gnu.org
Subject: Re: master d02c2f7 4/4: Speed up maybe_gc when GC is inhibited
Date: Sun, 21 Jul 2019 18:58:03 +0000	[thread overview]
Message-ID: <CAOqdjBesVq=Pz7S-7UE-NaC0X46Pg7H1OCiFryY4nzNBZZ4ByA@mail.gmail.com> (raw)
In-Reply-To: <20190721182420.CA41920BE2@vcs0.savannah.gnu.org>

On Sun, Jul 21, 2019 at 6:24 PM Paul Eggert <eggert@cs.ucla.edu> wrote:
>  static void
> -allow_garbage_collection (void)
> +allow_garbage_collection (void *ptr)
>  {
> +  object_ct *p = ptr;
> +  consing_until_gc = *p;
>    garbage_collection_inhibited--;
>  }
>
> @@ -5513,9 +5516,10 @@ ptrdiff_t
>  inhibit_garbage_collection (void)
>  {
>    ptrdiff_t count = SPECPDL_INDEX ();
> -
> -  record_unwind_protect_void (allow_garbage_collection);
> +  object_ct consing = consing_until_gc;
> +  record_unwind_protect_ptr (allow_garbage_collection, &consing);
>    garbage_collection_inhibited++;
> +  consing_until_gc = OBJECT_CT_MAX;
>    return count;
>  }

This looks unsafe to me. `consing' goes out of scope when
inhibit_garbage_collection returns, at which point the stack space for
`consing' will be reused for something else.
`allow_garbage_collection' is called later, and accesses what's
essentially random stack data.

Or am I missing something?

_______________________________________________
Emacs-diffs mailing list
Emacs-diffs@gnu.org
https://lists.gnu.org/mailman/listinfo/emacs-diffs

       reply	other threads:[~2019-07-21 18:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190721182418.6344.52048@vcs0.savannah.gnu.org>
     [not found] ` <20190721182420.CA41920BE2@vcs0.savannah.gnu.org>
2019-07-21 18:58   ` Pip Cet [this message]
2019-07-21 19:33     ` [Emacs-diffs] master d02c2f7 4/4: Speed up maybe_gc when GC is inhibited Paul Eggert
     [not found] ` <20190721182420.57AA720BE2@vcs0.savannah.gnu.org>
2019-07-22 13:36   ` [Emacs-diffs] master cf28594 2/4: Improve doc for hash tables Stefan Monnier
2019-07-23  4:33     ` Paul Eggert

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='CAOqdjBesVq=Pz7S-7UE-NaC0X46Pg7H1OCiFryY4nzNBZZ4ByA@mail.gmail.com' \
    --to=pipcet@gmail.com \
    --cc=eggert@cs.ucla.edu \
    --cc=emacs-devel@gnu.org \
    --cc=emacs-diffs@gnu.org \
    /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.