From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: YAMAMOTO Mitsuharu Newsgroups: gmane.emacs.bugs Subject: bug#6301: 23.2.50; GC may lose Lisp objects in the image cache Date: Mon, 11 Oct 2010 14:47:41 +0900 Organization: Faculty of Science, Chiba University Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII X-Trace: dough.gmane.org 1286777536 15273 80.91.229.12 (11 Oct 2010 06:12:16 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 11 Oct 2010 06:12:16 +0000 (UTC) To: 6301@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Oct 11 08:12:14 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1P5BcJ-0007vq-DY for geb-bug-gnu-emacs@m.gmane.org; Mon, 11 Oct 2010 08:12:11 +0200 Original-Received: from localhost ([127.0.0.1]:42828 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P5BcI-0007yF-M4 for geb-bug-gnu-emacs@m.gmane.org; Mon, 11 Oct 2010 02:12:10 -0400 Original-Received: from [140.186.70.92] (port=56089 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P5BcD-0007y9-0q for bug-gnu-emacs@gnu.org; Mon, 11 Oct 2010 02:12:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P5BcB-00047E-QC for bug-gnu-emacs@gnu.org; Mon, 11 Oct 2010 02:12:04 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:54738) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P5BcB-00047A-NH for bug-gnu-emacs@gnu.org; Mon, 11 Oct 2010 02:12:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1P5BC3-00055T-5J; Mon, 11 Oct 2010 01:45:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: YAMAMOTO Mitsuharu Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 11 Oct 2010 05:45:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6301 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 6301-submit@debbugs.gnu.org id=B6301.128677586519535 (code B ref 6301); Mon, 11 Oct 2010 05:45:03 +0000 Original-Received: (at 6301) by debbugs.gnu.org; 11 Oct 2010 05:44:25 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P5BBQ-000552-Vw for submit@debbugs.gnu.org; Mon, 11 Oct 2010 01:44:25 -0400 Original-Received: from mathmail.math.s.chiba-u.ac.jp ([133.82.132.2]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P5BBN-00054x-PM for 6301@debbugs.gnu.org; Mon, 11 Oct 2010 01:44:23 -0400 Original-Received: from church.math.s.chiba-u.ac.jp (church [133.82.132.36]) by mathmail.math.s.chiba-u.ac.jp (Postfix) with ESMTP id F2F0CC0561 for <6301@debbugs.gnu.org>; Mon, 11 Oct 2010 14:47:41 +0900 (JST) In-Reply-To: User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (=?UTF-8?Q?Shij=C5=8D?=) APEL/10.6 Emacs/22.3 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 11 Oct 2010 01:45:03 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:40802 Archived-At: >>>>> On Sat, 29 May 2010 17:37:43 +0900, YAMAMOTO Mitsuharu said: > Currently, Fgarbage_collect calls mark_terminals after marking > staticpro'ed objects. Terminal objects need a special marking > strategy with respect to image cache, but if a terminal object is > reachable from some staticpro'ed object, then it is marked normally > (i.e., without considering image cache). As a result, Lisp objects in > the image cache might be collected though they should have been > marked. > The simplest way to fix this would be to call mark_terminals earlier. On second thought, the following change would be more natural. === modified file 'src/alloc.c' *** src/alloc.c 2010-01-22 09:10:04 +0000 --- src/alloc.c 2010-10-10 01:56:51 +0000 *************** mark_terminals (void) *** 5771,5783 **** for (t = terminal_list; t; t = t->next_terminal) { eassert (t->name != NULL); - if (!VECTOR_MARKED_P (t)) - { #ifdef HAVE_WINDOW_SYSTEM ! mark_image_cache (t->image_cache); #endif /* HAVE_WINDOW_SYSTEM */ ! mark_vectorlike ((struct Lisp_Vector *)t); ! } } } --- 5779,5789 ---- for (t = terminal_list; t; t = t->next_terminal) { eassert (t->name != NULL); #ifdef HAVE_WINDOW_SYSTEM ! mark_image_cache (t->image_cache); #endif /* HAVE_WINDOW_SYSTEM */ ! if (!VECTOR_MARKED_P (t)) ! mark_vectorlike ((struct Lisp_Vector *)t); } } Also, as for stack marking, I noticed that about half of the stack elements have Lisp_Int* tags at least on Mac OS X. Such an element might be either a real Lisp integer or an aligned pointer value. We can omit mem_find calls for them by checking the tag value early. === modified file 'src/alloc.c' *** src/alloc.c 2010-01-22 09:10:04 +0000 --- src/alloc.c 2010-10-10 01:56:51 +0000 *************** static INLINE void *** 4109,4117 **** mark_maybe_object (obj) Lisp_Object obj; { ! void *po = (void *) XPNTR (obj); ! struct mem_node *m = mem_find (po); if (m != MEM_NIL) { int mark_p = 0; --- 4109,4125 ---- mark_maybe_object (obj) Lisp_Object obj; { ! void *po; ! struct mem_node *m; ! ! switch (XTYPE (obj)) ! { ! case_Lisp_Int: ! return; ! } + po = (void *) XPNTR (obj); + m = mem_find (po); if (m != MEM_NIL) { int mark_p = 0; YAMAMOTO Mitsuharu mituharu@math.s.chiba-u.ac.jp