From: Eli Zaretskii <eliz@gnu.org>
To: emacs-devel@gnu.org
Cc: Fabrice Popineau <fabrice.popineau@gmail.com>
Subject: GC and stack marking
Date: Mon, 19 May 2014 19:31:46 +0300 [thread overview]
Message-ID: <83a9add91p.fsf@gnu.org> (raw)
I have a question regarding GC and stack marking.
This issue popped up during testing of the new code written by Fabrice
for managing Emacs memory on MS-Windows. I don't think this issue is
Windows specific, and I don't think the details of the new
implementation matter for what I'm about to ask (but if someone wants
the gory details, please holler).
The short version of the question is: is it possible that a Lisp
object which is no longer referenced by anything won't be GC'ed
because it is marked by mark_stack due to some kind of coincidence?
The specific situation where I think I see something like this is
during dumping. When temacs loads and runs loadup.el, it does this
near the beginning:
(if (eq t purify-flag)
(setq purify-flag (make-hash-table :test 'equal :size 70000)))
This creates a large hash-table and stores its reference in
purify-flag. Then, after loading all the preloaded packages, temacs
does this:
;; Avoid error if user loads some more libraries now and make sure the
;; hash-consing hash table is GC'd.
(setq purify-flag nil)
(if (null (garbage-collect))
(setq pure-space-overflow t))
Note the comment: "...and make sure the hash-consing hash table is
GC'd.". Well, on one machine to which I have access, it isn't GC'd.
Why? because mark_stack happens to find its address somewhere on the
stack. (I have a backtrace to prove it.) So the huge hash-table gets
dumped into the emacs executable, and causes all kinds of trouble in
the dumped Emacs.
On another machine (with a different version of the OS and of GCC),
the problem doesn't happen, and the table is indeed GC'd.
My question is: is this a legitimate situation? Since all mark_stack
does is look for values recorded in the red-black tree, it might find
such a value by sheer luck (or lack thereof). Right? Or is this a
bug that needs to be researched further?
If this can legitimately happen, then how can we make sure this
hash-table indeed gets GC'd before we dump Emacs?
TIA
next reply other threads:[~2014-05-19 16:31 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-19 16:31 Eli Zaretskii [this message]
2014-05-19 18:47 ` GC and stack marking Paul Eggert
2014-05-19 19:14 ` Eli Zaretskii
2014-05-19 19:58 ` Paul Eggert
2014-05-19 20:03 ` Eli Zaretskii
2014-05-19 20:17 ` Paul Eggert
2014-05-20 16:37 ` Eli Zaretskii
2014-05-20 13:44 ` Stefan Monnier
2014-05-20 16:57 ` Eli Zaretskii
2014-05-20 17:54 ` Stefan Monnier
2014-05-20 19:28 ` Eli Zaretskii
2014-05-20 22:01 ` Stefan Monnier
2014-05-21 2:48 ` Eli Zaretskii
2014-05-21 3:01 ` Stefan Monnier
2014-05-21 15:39 ` Eli Zaretskii
2014-05-21 15:57 ` Dmitry Antipov
2014-05-21 16:06 ` Dmitry Antipov
2014-05-21 16:55 ` Eli Zaretskii
2014-05-21 16:53 ` Eli Zaretskii
2014-05-21 17:40 ` Stefan Monnier
2014-05-21 17:58 ` Eli Zaretskii
2014-05-22 15:20 ` Eli Zaretskii
2014-05-22 16:14 ` Stefan Monnier
2014-05-24 12:03 ` Eli Zaretskii
2014-05-20 19:12 ` Daniel Colascione
2014-05-20 19:43 ` Eli Zaretskii
2014-05-20 22:03 ` Stefan Monnier
2014-05-21 2:51 ` Eli Zaretskii
2014-05-31 6:31 ` Florian Weimer
2014-05-31 14:24 ` Stefan Monnier
-- strict thread matches above, loose matches on Subject: below --
2014-05-21 19:31 Barry OReilly
2014-05-21 20:13 ` Eli Zaretskii
2014-05-21 20:49 ` Barry OReilly
2014-05-22 2:43 ` Eli Zaretskii
2014-05-22 3:12 ` Daniel Colascione
2014-05-22 5:37 ` David Kastrup
2014-05-22 13:57 ` Stefan Monnier
2014-05-22 15:49 ` Eli Zaretskii
2014-05-22 14:59 ` Barry OReilly
2014-05-22 17:03 ` Eli Zaretskii
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=83a9add91p.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=fabrice.popineau@gmail.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.