From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: GC and stack marking Date: Mon, 19 May 2014 19:31:46 +0300 Message-ID: <83a9add91p.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1400517146 21288 80.91.229.3 (19 May 2014 16:32:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 19 May 2014 16:32:26 +0000 (UTC) Cc: Fabrice Popineau To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon May 19 18:32:19 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WmQTs-0005ux-98 for ged-emacs-devel@m.gmane.org; Mon, 19 May 2014 18:32:04 +0200 Original-Received: from localhost ([::1]:49185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmQTr-0001Ix-NN for ged-emacs-devel@m.gmane.org; Mon, 19 May 2014 12:32:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56976) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmQTg-00017I-0u for emacs-devel@gnu.org; Mon, 19 May 2014 12:31:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WmQTW-0001jn-Qf for emacs-devel@gnu.org; Mon, 19 May 2014 12:31:51 -0400 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:38082) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmQTW-0001jb-JG for emacs-devel@gnu.org; Mon, 19 May 2014 12:31:42 -0400 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0N5T00800XVM4700@a-mtaout22.012.net.il> for emacs-devel@gnu.org; Mon, 19 May 2014 19:31:41 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0N5T007LZXWSZD40@a-mtaout22.012.net.il>; Mon, 19 May 2014 19:31:41 +0300 (IDT) X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 80.179.55.172 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:171935 Archived-At: 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