GNU bug report logs -
#3863
23.1.50; possible save-match-data in copyright.el
Previous Next
Reported by: Kevin Ryde <user42 <at> zip.com.au>
Date: Thu, 16 Jul 2009 00:10:05 UTC
Severity: normal
Done: Kevin Ryde <user42 <at> zip.com.au>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 3863 in the body.
You can then email your comments to 3863 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#3863
; Package
emacs
.
(Thu, 16 Jul 2009 00:10:05 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Kevin Ryde <user42 <at> zip.com.au>
:
New bug report received and forwarded. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Thu, 16 Jul 2009 00:10:05 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):
[Message part 1 (text/plain, inline)]
In recent copyright.el I noticed copyright-update using the match data
after a y-or-n-p query. Is that a good idea?
When running it in emacs 22 I seemed to sometimes get the match data
clobbered by y-or-n-p. I never tracked down the circumstances, but
wondered if copyright.el shouldn't rely on what an input func like
y-or-n-p could do, per diff below.
In GNU Emacs 23.1.50.1 (i586-pc-linux-gnu, GTK+ Version 2.16.4)
of 2009-07-12 on blah.blah
configured using `configure 'CFLAGS=-O -g' '--prefix=/down/emacs/b/inst' '--with-x-toolkit=gtk''
Important settings:
value of $LC_ALL: nil
value of $LC_COLLATE: nil
value of $LC_CTYPE: nil
value of $LC_MESSAGES: nil
value of $LC_MONETARY: nil
value of $LC_NUMERIC: nil
value of $LC_TIME: nil
value of $LANG: en_AU
value of $XMODIFIERS: nil
locale-coding-system: iso-latin-1-unix
default-enable-multibyte-characters: t
2009-07-16 Kevin Ryde <user42 <at> zip.com.au>
* emacs-lisp/copyright.el (copyright-update): save-match-data across
y-or-n-p, for safety.
[copyright.el.save-match-data.diff (text/x-diff, inline)]
*** copyright.el 16 Jul 2009 09:44:20 +1000 1.81
--- copyright.el 16 Jul 2009 09:55:57 +1000
***************
*** 223,230 ****
(< (string-to-number (match-string 3))
(string-to-number copyright-current-gpl-version))
(or noquery
! (y-or-n-p (format "Replace GPL version by %s? "
! copyright-current-gpl-version)))
(progn
(if (match-end 2)
;; Esperanto bilingual comment in two-column.el
--- 223,231 ----
(< (string-to-number (match-string 3))
(string-to-number copyright-current-gpl-version))
(or noquery
! (save-match-data
! (y-or-n-p (format "Replace GPL version by %s? "
! copyright-current-gpl-version))))
(progn
(if (match-end 2)
;; Esperanto bilingual comment in two-column.el
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#3863
; Package
emacs
.
(Thu, 16 Jul 2009 02:10:04 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Thu, 16 Jul 2009 02:10:04 GMT)
Full text and
rfc822 format available.
Message #10 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):
> 2009-07-16 Kevin Ryde <user42 <at> zip.com.au>
> * emacs-lisp/copyright.el (copyright-update): save-match-data across
> y-or-n-p, for safety.
Thanks, installed,
Stefan
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#3863
; Package
emacs
.
(Thu, 16 Jul 2009 02:10:06 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Thu, 16 Jul 2009 02:10:06 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#3863
; Package
emacs
.
(Thu, 16 Jul 2009 16:05:04 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Chong Yidong <cyd <at> stupidchicken.com>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Thu, 16 Jul 2009 16:05:04 GMT)
Full text and
rfc822 format available.
Message #20 received at 3863 <at> emacsbugs.donarmstrong.com (full text, mbox):
> In recent copyright.el I noticed copyright-update using the match data
> after a y-or-n-p query. Is that a good idea?
>
> When running it in emacs 22 I seemed to sometimes get the match data
> clobbered by y-or-n-p.
If so, we should change y-or-n-p to save the match data. Could you
provide a reproducible test-case for the clobbering of the match data?
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#3863
; Package
emacs
.
(Thu, 16 Jul 2009 17:30:04 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Thu, 16 Jul 2009 17:30:04 GMT)
Full text and
rfc822 format available.
Message #25 received at 3863 <at> emacsbugs.donarmstrong.com (full text, mbox):
> If so, we should change y-or-n-p to save the match data.
Why? y-or-n-p will yield waiting for user input, so it's basically
a point where any other code can run. It's one of the prime examples of
a function which you can't expect to preserve the match-data.
Stefan
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#3863
; Package
emacs
.
(Thu, 16 Jul 2009 18:50:04 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Lennart Borgman <lennart.borgman <at> gmail.com>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Thu, 16 Jul 2009 18:50:04 GMT)
Full text and
rfc822 format available.
Message #30 received at 3863 <at> emacsbugs.donarmstrong.com (full text, mbox):
On Thu, Jul 16, 2009 at 7:24 PM, Stefan Monnier<monnier <at> iro.umontreal.ca> wrote:
>> If so, we should change y-or-n-p to save the match data.
>
> Why? y-or-n-p will yield waiting for user input, so it's basically
> a point where any other code can run. It's one of the prime examples of
> a function which you can't expect to preserve the match-data.
I don't think I understand, but it sounds like this is a reason why
y-or-n-p should save match-data...
Is there any reason not to let y-or-n-p save match data? I mean the
function needing match data possibly want yield until it has used it,
or?
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#3863
; Package
emacs
.
(Thu, 16 Jul 2009 19:00:04 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Chong Yidong <cyd <at> stupidchicken.com>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Thu, 16 Jul 2009 19:00:04 GMT)
Full text and
rfc822 format available.
Message #35 received at 3863 <at> emacsbugs.donarmstrong.com (full text, mbox):
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
> Why? y-or-n-p will yield waiting for user input, so it's basically
> a point where any other code can run. It's one of the prime examples of
> a function which you can't expect to preserve the match-data.
I'm not sure what you're referring to. What other code runs during
y-or-n-p (excluding timers, which are supposed to save the match data)?
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#3863
; Package
emacs
.
(Fri, 17 Jul 2009 03:30:04 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Fri, 17 Jul 2009 03:30:04 GMT)
Full text and
rfc822 format available.
Message #40 received at 3863 <at> emacsbugs.donarmstrong.com (full text, mbox):
> I don't think I understand, but it sounds like this is a reason why
> y-or-n-p should save match-data...
Here we go again:
All functions destroy the match-data except for a few rare exceptions,
which are simple functions doing little work.
> Is there any reason not to let y-or-n-p save match data?
If you think y-or-n-p deserves saving the match-data then pretty much
all other functions deserve that change as well. And since
save-match-data is somewhat costly, it would imply a singificant
performance impact.
Stefan
PS: Worse yet: during y-or-n-p, the buffer might be completely changed
by the code run asynchronously, so the "saved" match data may not even
have any meaning any more.
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#3863
; Package
emacs
.
(Fri, 17 Jul 2009 03:30:06 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Fri, 17 Jul 2009 03:30:06 GMT)
Full text and
rfc822 format available.
Message #45 received at 3863 <at> emacsbugs.donarmstrong.com (full text, mbox):
> I'm not sure what you're referring to. What other code runs during
> y-or-n-p (excluding timers, which are supposed to save the match data)?
Timers,
Stefan
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#3863
; Package
emacs
.
(Fri, 17 Jul 2009 04:05:04 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Lennart Borgman <lennart.borgman <at> gmail.com>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Fri, 17 Jul 2009 04:05:04 GMT)
Full text and
rfc822 format available.
Message #50 received at 3863 <at> emacsbugs.donarmstrong.com (full text, mbox):
On Fri, Jul 17, 2009 at 5:23 AM, Stefan Monnier<monnier <at> iro.umontreal.ca> wrote:
>> I don't think I understand, but it sounds like this is a reason why
>> y-or-n-p should save match-data...
>
> Here we go again:
>
> All functions destroy the match-data except for a few rare exceptions,
> which are simple functions doing little work.
>
>> Is there any reason not to let y-or-n-p save match data?
>
> If you think y-or-n-p deserves saving the match-data then pretty much
> all other functions deserve that change as well. And since
> save-match-data is somewhat costly, it would imply a singificant
> performance impact.
Sorry, I just meant that since the functions that prompts the user
can't really impact performance if we just add save-match-data to them
we could do that just to get some more protection.
It does not cure the problem that some functions running in timers
forgets to save match data, but perhaps it catches some actually
occuring problem cases.
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#3863
; Package
emacs
.
(Fri, 17 Jul 2009 08:05:05 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
martin rudalics <rudalics <at> gmx.at>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Fri, 17 Jul 2009 08:05:05 GMT)
Full text and
rfc822 format available.
Message #55 received at 3863 <at> emacsbugs.donarmstrong.com (full text, mbox):
> If you think y-or-n-p deserves saving the match-data then pretty much
> all other functions deserve that change as well. And since
> save-match-data is somewhat costly, it would imply a singificant
> performance impact.
You're obviously right and I meanwhile also learned to share your
earlier reservations wrt `looking-at-p' and `string-match-p'. However,
the underlying problem deserves a profound explanation in the Elisp
manual in oder to avoid such discussions in the future. So please,
pretty please, write one.
martin
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#3863
; Package
emacs
.
(Fri, 17 Jul 2009 14:50:04 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Chong Yidong <cyd <at> stupidchicken.com>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Fri, 17 Jul 2009 14:50:05 GMT)
Full text and
rfc822 format available.
Message #60 received at 3863 <at> emacsbugs.donarmstrong.com (full text, mbox):
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>> I'm not sure what you're referring to. What other code runs during
>> y-or-n-p (excluding timers, which are supposed to save the match data)?
>
> Timers,
As the Lisp manual states,
If a timer function calls functions that can change the match data,
it should save and restore the match data.
If a timer fails to do this, it's a bug, and should be fixed.
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#3863
; Package
emacs
.
(Fri, 17 Jul 2009 16:05:07 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Stefan Monnier <monnier <at> IRO.UMontreal.CA>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Fri, 17 Jul 2009 16:05:08 GMT)
Full text and
rfc822 format available.
Message #65 received at 3863 <at> emacsbugs.donarmstrong.com (full text, mbox):
>>> I'm not sure what you're referring to. What other code runs during
>>> y-or-n-p (excluding timers, which are supposed to save the match data)?
>>
>> Timers,
> As the Lisp manual states,
> If a timer function calls functions that can change the match data,
> it should save and restore the match data.
> If a timer fails to do this, it's a bug, and should be fixed.
Wonderful, so we all agree there's no need to make y-or-n-p save the
match-data.
Stefan
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#3863
; Package
emacs
.
(Thu, 06 Aug 2009 01:05:04 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Kevin Ryde <user42 <at> zip.com.au>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Thu, 06 Aug 2009 01:05:04 GMT)
Full text and
rfc822 format available.
Message #70 received at 3863 <at> emacsbugs.donarmstrong.com (full text, mbox):
Chong Yidong <cyd <at> stupidchicken.com> writes:
>
> Could you
> provide a reproducible test-case for the clobbering of the match data?
When I struck it, which is a while ago now, it was intermittent. It
could even have been some of my own input defadvice stuff, though I
thought it wasn't.
Reply sent
to
Kevin Ryde <user42 <at> zip.com.au>
:
You have taken responsibility.
(Fri, 02 Oct 2009 00:20:06 GMT)
Full text and
rfc822 format available.
Notification sent
to
Kevin Ryde <user42 <at> zip.com.au>
:
bug acknowledged by developer.
(Fri, 02 Oct 2009 00:20:07 GMT)
Full text and
rfc822 format available.
Message #75 received at 3863-done <at> emacsbugs.donarmstrong.com (full text, mbox):
Closing for,
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>
> installed,
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> emacsbugs.donarmstrong.com
.
(Fri, 30 Oct 2009 14:24:13 GMT)
Full text and
rfc822 format available.
This bug report was last modified 15 years and 238 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.