all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Vibhav Pant <vibhavp@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: [PATCH] Make purecopy create hash tables properly
Date: Sat, 28 Jan 2017 15:55:08 +0530	[thread overview]
Message-ID: <CA+T2Sh1YM1GcVTVV2ZvuSQB_WwfRMB1sD5kYR4dCajqyMbi2+g@mail.gmail.com> (raw)
In-Reply-To: <jwv60l0p0vp.fsf-monnier+gmane.emacs.devel@gnu.org>

On Sat, Jan 28, 2017 at 4:40 AM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
> Whichever option you take, please pay attention to `next_weak` because
> in your patch, you'll end up purecopying some of the other weak
> hash-tables but you won't register this one as a weak hash table, so it
> will lead to serious problems.

Not sure if I'm correct here, but shouldn't we be *not* purecopying weak hash
tables? Otherwise, GC will result in potentially writing over/freeing pure
memory, something that we don't want to happen. Plus, I think that this opens
another can of worms for code like this:

(let ((h #s(hash-table data ())))
  (puthash 'foo 'bar h))

or

(defun a ()
 #s(hash-table data ())) ;; the returned table might be purecopied
                                     ;; and the callee might write to it

Which also writes to pure storage if the code is purecopied during
dumping emacs.
I'd recommend skipping purecopy for hash tables altogether, and add an
internal :read-only flag to (make-hash-table) for hash tables we know aren't
going to be be written to, and are thus safe to be purecopied (this would
obviously only be useful for hash tables that are defined using printed syntax).

-- 
Vibhav Pant
vibhavp@gmail.com



  reply	other threads:[~2017-01-28 10:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-27 18:37 [PATCH] Make purecopy create hash tables properly Vibhav Pant
2017-01-27 22:06 ` Paul Eggert
2017-01-27 23:10 ` Stefan Monnier
2017-01-28 10:25   ` Vibhav Pant [this message]
2017-01-28 10:26     ` Vibhav Pant
2017-01-28 14:58     ` Stefan Monnier
2017-01-28 20:06       ` Vibhav Pant
2017-01-29  2:18         ` Stefan Monnier
2017-01-29 17:23       ` Vibhav Pant
2017-01-29 17:58         ` Stefan Monnier
2017-01-29 19:14           ` Vibhav Pant
2017-01-29 19:41             ` Stefan Monnier
2017-01-30 12:43               ` Vibhav Pant

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=CA+T2Sh1YM1GcVTVV2ZvuSQB_WwfRMB1sD5kYR4dCajqyMbi2+g@mail.gmail.com \
    --to=vibhavp@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.