Hi Richard, >You have made significant progress, but we don't know the answer yet. > >Can you determine where that data becomes corrupted? >Is it written wrong at the start, or does it get >clobbered later on? > Thank you for your support! I worked hard to find the bug that corrupted menu strings, and I think I finally found it! In fact, after displaying memory locations of menu item strings in `widget_value' data structures, I noticed that sometimes their contents changed (not the location) between their initialization in `single_submenu' and their use in `add_menu_item'. This looked like a bad interaction with GC. I carefully reviewed the code and was first disappointed because all the Lisp strings that produced menu item strings seemed correctly protected from GC! I looked more thoroughly at the GC code, and discovered that the data part of Lisp strings may be relocated when GC compacts the Lisp string storage. Even when the base string Lisp_Object is protected! So, I hacked w32menu.c to used safe local copy of menu item strings, and the bug disappeared :-) From that base, I took time to properly update w32menu.c, and fixed another bug too, related to pop up menu cleanup. Finally I cleaned up the code to generalize use of AREF, ASET and ASIZE macros. Attached you will find the patch, the change log is at end. With the patch menus work very well now, with no noticeable slow down (I used the faster Win32 API to alloc/free memory). I don't know if it is possible, or if that could solve such problems (is it guaranteed that GC can't raise when a menu is showing up?), but perhaps a more general solution, probably with more impact, would be to directly use Lisp strings in `widget_value', like for help items? What do you think? Sincerely, David ------------------------ Change Log -------------------------------- (local_heap, local_alloc, local_free): New macros. (malloc_widget_value, free_widget_value) (free_menubar_widget_value_tree) (w32_free_submenu_strings): Use them. (local-string): New function. (single_submenu, set_frame_menubar) (w32_menu_show, add_menu_item): Use it. (push_submenu_start, push_submenu_end, push_left_right_boundary) (push_menu_pane, push_menu_item, single_keymap_panes) (single_menu_item, Fx_popup_menu, menubar_selection_callback) (single_submenu, set_frame_menubar) (w32_menu_show, w32_dialog_show): Use AREF, ASET, ASIZE. (Fx_popup_menu): Don't show pop up menu until preceding one is actually cleaned up. Moved UNGCPRO outside #ifdef HAVE_MENUS block.