Subject: Re: bug#451: 23.0.60; x-gtk-map-stock destroys match data

From: Nick Roberts <[email-masked]>
Date: Sat, 21 Jun 2008 11:01:17 +1200

> > In the event loop (?), update_frame_tool_bar calls x-gtk-map-stock (in
 > > x-win.el) which uses string-match.  This changes the match data that
 > > I need for my application.  I don't know what the rules are about
 > > using string-match from C code but as a minimum x-gtk-map-stock should
 > > wrap save-match-data around the call to it.
 > 
 > The match-data is a very volatile piece of data.  So while you may be
 > right, I think it's more likely that the problem is in your code
 > (i.e., your code should save the match-data itself if it needs to use
 > it after some non-trivial code has been run, and by "trivial" I *really*
 > mean trivial).

I don't think that's right.  The problem goes away if I remove the tool bar.
If I do:

(string-match "ox" "The quick lazy fox jumped")

in the *scratch* buffer then

(match-beginning 0)
(match-end 0)

give me false values immediately afterwards.

Presumably update_frame_tool_bar gets called in between the evaluations.  I'm
not sure exactly why it's called but I have:

(add-hook 'gdb-mode-hook
'(lambda ()
   (tool-bar-mode 1)
   (if (eq window-system 'x)
       (define-key-after gud-tool-bar-map [function-step]
	 '(menu-item "Step outer" gud-function-step
		     :image (image :type xpm
		     :file "/home/nickrob/emacs/etc/images/jump-to.xpm")
		     :enable (not gud-running)
		     :visible (memq gud-minor-mode '(gdbmi gdba)))))))

in my .emacs

-- 
Nick                                           http://www.inet.net.nz/~nickrob