Subject: Re: bug#21824: 25.0.50; overlay modification-hooks called with wrong buffer

From: Noam Postavsky <[email-masked]>
Date: Thu, 5 Nov 2015 22:14:28 -0500

Okay, turned out flycheck was basically irrelevant except that it
calls message a lot. And highlight-parentheses' only significance is
that it makes overlays all over the place. I have a simple reproducer,
run as

     emacs -Q -l bug-21824.el -f 21824-trigger

The required circumstances appear to be that after a modification-hook
has been run and there is an overlay in the *Messages* buffer, the
message coalescing (the "[2 times]" thing) wrongly causes runs the
modification-hook of the overlay in the 1st buffer, but with
parameters from the  *Messages* buffer modification.

A sample backtrace (I put a call to `debug' when the current-buffer is
incorrect).

Debugger entered: (#<overlay from 2 to 5 in foo.cpp> t 223 223 10
#<buffer *Messages*>)
  (if (eq (current-buffer) (overlay-buffer overlay)) (message
"21842-mod-overlay(%s %s %s %s %s), buf = %s" overlay afterp beg end
len (current-buffer)) (setq 21842-repeat-message) (debug nil overlay
afterp beg end len (current-buffer)))
  21824-mod-overlay(#<overlay from 2 to 5 in foo.cpp> t 223 223 10)
  message("a message")
  21824-trigger()
  command-line-1(("-l" "bug-21824.el" "-f" "21824-trigger"))
  command-line()
  normal-top-level()