unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: GC and stack marking
@ 2014-05-21 19:31 Barry OReilly
  2014-05-21 20:13 ` Eli Zaretskii
  0 siblings, 1 reply; 40+ messages in thread
From: Barry OReilly @ 2014-05-21 19:31 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 339 bytes --]

> It might simply be a slot that's unused by the current stack frame,
> whose value comes from some stack frame that existed some time in
> the past.

So should the relevant C code try to initialize variables with non
garbage? I took a look at Fgarbage_collect and found that the
stack_top_variable variable for example is garbage valued.

[-- Attachment #2: Type: text/html, Size: 402 bytes --]

^ permalink raw reply	[flat|nested] 40+ messages in thread
* GC and stack marking
@ 2014-05-19 16:31 Eli Zaretskii
  2014-05-19 18:47 ` Paul Eggert
  2014-05-20 13:44 ` Stefan Monnier
  0 siblings, 2 replies; 40+ messages in thread
From: Eli Zaretskii @ 2014-05-19 16:31 UTC (permalink / raw)
  To: emacs-devel; +Cc: Fabrice Popineau

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



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

end of thread, other threads:[~2014-05-31 14:24 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-21 19:31 GC and stack marking 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
  -- strict thread matches above, loose matches on Subject: below --
2014-05-19 16:31 Eli Zaretskii
2014-05-19 18:47 ` 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

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).