unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "David PONCE" <David.Ponce@wanadoo.fr>
Cc: <emacs-devel@gnu.org>
Subject: Re: NT Emacs crashes when selecting a menubar item
Date: Tue, 30 Jul 2002 13:28:32 +0200 (MET DST)	[thread overview]
Message-ID: <4726.43486359647$1028024941@news.gmane.org> (raw)

Richard,

I can confirm that GC is the cause of the problem.  I printed
messages before, after, and in the middle of the loop that build the
widget_value tree and when entering GC.  Here is a snippet of printed
result that clearly shows that GC happened while running
single_submenu:

[...]
w32menu.set_frame_menubar before init_menu_items consing/threshold(375580/134217727)
w32menu.set_frame_menubar before single_submenu consing/threshold(375580/134217727)
w32menu.set_frame_menubar after single_submenu consing/threshold(376568/134217727)
w32menu.set_frame_menubar before single_submenu consing/threshold(376568/134217727)
w32menu.set_frame_menubar after single_submenu consing/threshold(466128/134217727)
w32menu.set_frame_menubar before single_submenu consing/threshold(466128/134217727)
w32menu.set_frame_menubar after single_submenu consing/threshold(485808/134217727)
w32menu.set_frame_menubar before single_submenu consing/threshold(485808/134217727)
w32menu.set_frame_menubar after single_submenu consing/threshold(485920/134217727)
w32menu.set_frame_menubar before single_submenu consing/threshold(485920/134217727)
w32menu.set_frame_menubar after single_submenu consing/threshold(486276/134217727)
w32menu.set_frame_menubar before single_submenu consing/threshold(486276/134217727)
w32menu.set_frame_menubar after single_submenu consing/threshold(501404/134217727)
w32menu.set_frame_menubar before single_submenu consing/threshold(501404/134217727)
*** GC entered consing/threshold(509952/10000000)
*** GC entered consing/threshold(872/10000000)
w32menu.set_frame_menubar after single_submenu consing/threshold(6444/134217727)
w32menu.set_frame_menubar before single_submenu consing/threshold(6444/134217727)
w32menu.set_frame_menubar after single_submenu consing/threshold(7120/134217727)
w32menu.set_frame_menubar before single_submenu consing/threshold(7120/134217727)
w32menu.set_frame_menubar after single_submenu consing/threshold(10568/134217727)
w32menu.set_frame_menubar before single_submenu consing/threshold(10568/134217727)
w32menu.set_frame_menubar after single_submenu consing/threshold(24800/134217727)
w32menu.set_frame_menubar before single_submenu consing/threshold(24800/134217727)
w32menu.set_frame_menubar after single_submenu consing/threshold(39056/134217727)
w32menu.set_frame_menubar before single_submenu consing/threshold(39056/134217727)
w32menu.set_frame_menubar after single_submenu consing/threshold(100504/134217727)
w32menu.set_frame_menubar after finish_menu_items consing/threshold(100504/134217727)
*** GC entered consing/threshold(101352/10000000)
[...]

In fact 10000000 is the `gc-cons-threshold' value that the Semantic
parser locally uses to speed up things.  The parser is called from
`menu-bar-update-hook' to produce the parse tree used to build the
imenu index.  And can be called too via an idle timer to re-parse the
buffer when necessary.  Also the parser explicitly calls
`garbage-collect' to free memory before it locally binds
`gc-cons-threshold'.  Maybe the parser hook or timer are
asynchronously activated while building the widget_value tree?

IMO it is definitively a bug in Emacs to consider that the range of
code that builds the menu tree is GC safe, because user's Lisp code
can call `garbage-collect' or re-bind `gc-cons-threshold' to a value
lower than the maximum one set by `inhibit_garbage_collection' to
inhibit GC.  As Lisp strings data can be relocated even if the
Lisp_Object is protected, it is only safe to store string data
locations when it is really sure that GC can't happen.

My proposed patch to w32menu.c make widget_value insensible to GC
because it only contains pointers to safe strings, copied in local
heap.  The counterpart is a little overhead.  From what I observed, I
didn't noticed a significant slow down when using menus.

Maybe another possible solution could be that
`inhibit_garbage_collection' uses a flag to block GC?  By default it
would be t to allow GC and could be set to nil to really disable GC.
Something like this:

(let ((inhibit_garbage_collection nil))
  (garbage_collect) ;; Does nothing!
 )

I don't know if a such flag should be exported to Lisp.  Perhaps its
use would be dangerous!

David

             reply	other threads:[~2002-07-30 11:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-30 11:28 David PONCE [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-08-01 11:39 NT Emacs crashes when selecting a menubar item David PONCE
2002-08-01  7:54 jasonr
     [not found] <3D2A791A00A0862A@mel-rta9.wanadoo.fr>
2002-07-31 21:57 ` Richard Stallman
2002-07-31 22:37   ` David Ponce
2002-07-24 18:55 David Ponce
2002-07-25 18:07 ` Richard Stallman
2002-07-26 12:30   ` David Ponce
2002-07-27 18:52     ` Richard Stallman
2002-07-28 16:56       ` David Ponce
2002-07-29 17:30         ` Richard Stallman
2002-07-29 18:16           ` David Ponce
2002-07-30 18:46             ` Richard Stallman

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='4726.43486359647$1028024941@news.gmane.org' \
    --to=david.ponce@wanadoo.fr \
    --cc=emacs-devel@gnu.org \
    /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 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).