Andy Piper <andy(a)xemacs.org> writes:
I suppose it might be worth rewriting your sledgehammer check to
validate
that for every instance in the frame cache its domain is (a) a window and
(b) in that window's cache.
I just did this (code at end)
I stuck it in Feval, Ffuncall, Fset_window_configuration and
before/after garbage_collect[1].
It hits in Feval all the time while starting up Gnus. I can sometimes
get it too when I make buffers with C-x b and play a lot with windows.
Still no clue what could cause it. Could you review my check?
Footnotes:
[1] In case it was some problem with the weak hash tables.
Jan
korteweg:/scratch/xemacs/xemacs-20/src> cvs diff glyphs.c lisp.h eval.c alloc.c
Index: glyphs.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs-20/src/glyphs.c,v
retrieving revision 1.23.2.72
diff -u -r1.23.2.72 glyphs.c
--- glyphs.c 2000/05/23 10:53:41 1.23.2.72
+++ glyphs.c 2000/05/26 08:40:39
@@ -592,6 +592,71 @@
check_window_subwindow_cache
(XWINDOW (XIMAGE_INSTANCE_DOMAIN (instance)));
}
+
+int inhibit_sledge_hammer_check = 0;
+
+static int found_in_cache = 0;
+
+static int
+find_instance_mapper (Lisp_Object key, Lisp_Object value,
+ void *flag_closure)
+{
+ /* This function can GC */
+ /* value can be nil; we cache failures as well as successes */
+ if (!NILP (value))
+ {
+ Lisp_Object instance;
+
+ VOID_TO_LISP (instance, flag_closure);
+ if (EQ (value, instance))
+ {
+ found_in_cache = 1;
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+static void
+check_image_instance_in_window_cache (Lisp_Object instance)
+{
+ struct window *w;
+
+ if (WINDOWP (XIMAGE_INSTANCE_DOMAIN (instance)))
+ {
+ w = XWINDOW (XIMAGE_INSTANCE_DOMAIN (instance));
+
+ assert (!NILP (w->subwindow_instance_cache));
+
+ found_in_cache = 0;
+
+ elisp_maphash (find_instance_mapper,
+ w->subwindow_instance_cache,
+ LISP_TO_VOID (instance));
+
+ assert (found_in_cache);
+ }
+}
+
+void
+check_subwindow_instance_caches (void)
+{
+ Lisp_Object frmcons, devcons, concons;
+
+ if (inhibit_sledge_hammer_check)
+ return;
+
+ FRAME_LOOP_NO_BREAK (frmcons, devcons, concons)
+ {
+ Lisp_Object rest;
+
+ LIST_LOOP (rest, XWEAK_LIST_LIST
+ (FRAME_SUBWINDOW_CACHE (XFRAME (XCAR (frmcons)))))
+ check_image_instance_in_window_cache (XCAR (rest));
+ }
+}
+
#endif
/* Determine what kind of domain governs the image instance.
@@ -3144,6 +3209,7 @@
& (IMAGE_SUBWINDOW_MASK | IMAGE_WIDGET_MASK))
assert (EQ (XIMAGE_INSTANCE_FRAME (instance),
DOMAIN_FRAME (domain)));
+ check_subwindow_instance_caches();
#endif
ERROR_CHECK_IMAGE_INSTANCE (instance);
return instance;
Index: lisp.h
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs-20/src/lisp.h,v
retrieving revision 1.38.2.64
diff -u -r1.38.2.64 lisp.h
--- lisp.h 2000/05/21 01:40:39 1.38.2.64
+++ lisp.h 2000/05/26 08:40:54
@@ -2351,6 +2351,9 @@
/* Defined in glyphs.c */
Error_behavior decode_error_behavior_flag (Lisp_Object);
Lisp_Object encode_error_behavior_flag (Error_behavior);
+#ifdef ERROR_CHECK_GLYPHS
+void check_subwindow_instance_caches (void);
+#endif
/* Defined in indent.c */
int bi_spaces_at_point (struct buffer *, Bytind);
Index: eval.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs-20/src/eval.c,v
retrieving revision 1.27.2.24
diff -u -r1.27.2.24 eval.c
--- eval.c 2000/05/17 07:35:45 1.27.2.24
+++ eval.c 2000/05/26 08:41:17
@@ -2939,6 +2939,10 @@
UNGCPRO;
}
+#ifdef ERROR_CHECK_GLYPHS
+ check_subwindow_instance_caches ();
+#endif
+
if (++lisp_eval_depth > max_lisp_eval_depth)
{
if (max_lisp_eval_depth < 100)
@@ -3162,6 +3166,8 @@
/* Callers should gcpro lexpr args */
garbage_collect_1 ();
+ check_subwindow_instance_caches();
+
if (++lisp_eval_depth > max_lisp_eval_depth)
{
if (max_lisp_eval_depth < 100)
Index: alloc.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs-20/src/alloc.c,v
retrieving revision 1.42.2.61
diff -u -r1.42.2.61 alloc.c
--- alloc.c 2000/05/01 11:00:02 1.42.2.61
+++ alloc.c 2000/05/26 08:41:37
@@ -3353,6 +3353,8 @@
f = XFRAME (frame);
}
+ check_subwindow_instance_caches();
+
pre_gc_cursor = Qnil;
cursor_changed = 0;
@@ -3561,6 +3563,8 @@
/* now stop inhibiting GC */
unbind_to (speccount, Qnil);
+
+ check_subwindow_instance_caches();
if (!breathing_space)
{
korteweg:/scratch/xemacs/xemacs-20/src> cvs diff window.c
Index: window.c
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs-20/src/window.c,v
retrieving revision 1.41.2.52
diff -u -r1.41.2.52 window.c
--- window.c 2000/05/11 10:29:37 1.41.2.52
+++ window.c 2000/05/26 08:57:44
@@ -1603,9 +1603,10 @@
(window))
{
struct window *w = decode_window (window);
+ struct frame *f = XFRAME (w->frame);
- int left = w->pixel_left;
- int top = w->pixel_top;
+ int left = w->pixel_left - FRAME_LEFT_BORDER_END (f) - FRAME_LEFT_GUTTER_BOUNDS(f);
+ int top = w->pixel_top - FRAME_TOP_BORDER_END (f) - FRAME_TOP_GUTTER_BOUNDS(f);;
return list4 (make_int (left),
make_int (top),
@@ -1941,6 +1942,8 @@
they don't sit around consuming excess space. They will be
reinitialized by the window-configuration code as necessary. */
finalize_window ((void *) w, 0);
+
+ check_subwindow_instance_caches();
}
DEFUN ("delete-window", Fdelete_window, 0, 2, "", /*
@@ -5218,7 +5221,16 @@
/* Force subwindows to be reinstantiated. They are all going
anyway and if we don't do this GC may not happen between now
- and the next time we check their integrity. */
+ and the next time we check their integrity.
+
+ #### JV: I don't understand this comment. Trying to be smart like
+ this and trying to do redisplay's work can cause problems
+ (See also comment in unmap_subwindow). In fact I don't follow
+ "all are going anyway" at all. Most calls of
+ Fset_windows_configuration
+ happen as part of save-window-excursion and have no redisplay
+ during the existance of the new state.
+ */
reset_frame_subwindow_instance_cache (f);
#if 0
@@ -5601,6 +5613,8 @@
UNGCPRO;
+ check_subwindow_instance_caches();
+
return Qnil;
}
korteweg:/scratch/xemacs/xemacs-20/src>