unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* mode-line-eol-desc needs to use assoc, not assq
@ 2008-12-20  7:11 Ami Fischman
  2008-12-20  7:20 ` Chong Yidong
  0 siblings, 1 reply; 2+ messages in thread
From: Ami Fischman @ 2008-12-20  7:11 UTC (permalink / raw)
  To: emacs-devel

mode-line-eol-desc uses assq to look up desc in
mode-line-eol-desc-cache, but the key used is computed by
coding-system-eol-type which returns a vector sometimes.  This results
in mode-line-eol-desc-cache growing without bounds over the lifetime
of an emacs process.  Changing mode-line-eol-desc to use assoc instead
of assq (so that the vectors are compared with equal and so have a
chance of returning t) fixes this.

Repro:
$ emacs -Q
eval (length mode-line-eol-desc-cache)
do this many times, the value is always 1.
eval (prefer-coding-system 'utf-8-emacs)
eval (length mode-line-eol-desc-cache)
do this many times; the value keeps increasing by 1 on every call(!).
C-h v mode-line-eol-desc-cache RET
eval (length mode-line-eol-desc-cache)
witness the returned value increasing by 3 for every C-h v
(describe-variable) as above.

Many innocuous actions such as visiting files and creating buffers
will cause this variable to grow with many many duplicate entries.

Drive the variable arbitrarily high by evaling:

(progn
  (dotimes (j 1000)
    (switch-to-buffer "does-not-exist")
    (kill-buffer)
    (redisplay))
  (insert (format "%d " (length mode-line-eol-desc-cache))))

In an emacs running for several days I've seen the variable get over
420,000 entries in it, according to prin1-to-string.

Making the s/assq/assoc/ change as above fixes all these repro cases.

-a




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: mode-line-eol-desc needs to use assoc, not assq
  2008-12-20  7:11 mode-line-eol-desc needs to use assoc, not assq Ami Fischman
@ 2008-12-20  7:20 ` Chong Yidong
  0 siblings, 0 replies; 2+ messages in thread
From: Chong Yidong @ 2008-12-20  7:20 UTC (permalink / raw)
  To: Ami Fischman; +Cc: emacs-devel

"Ami Fischman" <ami@fischman.org> writes:

> mode-line-eol-desc uses assq to look up desc in
> mode-line-eol-desc-cache, but the key used is computed by
> coding-system-eol-type which returns a vector sometimes.  This results
> in mode-line-eol-desc-cache growing without bounds over the lifetime
> of an emacs process.  Changing mode-line-eol-desc to use assoc instead
> of assq (so that the vectors are compared with equal and so have a
> chance of returning t) fixes this.

Checked in, thanks.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-12-20  7:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-20  7:11 mode-line-eol-desc needs to use assoc, not assq Ami Fischman
2008-12-20  7:20 ` Chong Yidong

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).