emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NT Emacs crashes when selecting a menubar item


From: David PONCE
Subject: Re: NT Emacs crashes when selecting a menubar item
Date: Tue, 30 Jul 2002 13:28:32 +0200 (MET DST)

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 via email to

[Prev in Thread] Current Thread [Next in Thread]