Subject: Re: bug#39207: WITH dgb symbols Re: bug#39207: 28.0.50; crash when sending gnus message

From: Robert Pluim <[email-masked]>
Date: Wed, 22 Jan 2020 21:39:46 +0100

>>>>> On Wed, 22 Jan 2020 19:37:04 +0200, Eli Zaretskii <[email-masked]> said:

    >> From: Robert Pluim <[email-masked]>
    >> Cc: [email-masked],  [email-masked]
    >> Date: Wed, 22 Jan 2020 17:58:12 +0100
    >> 
    >> (gdb) pp BVAR(current_buffer,enable_multibyte_characters)
    >> t
    >> (gdb)
    >> (gdb) pp BVAR(buffer,enable_multibyte_characters)
    >> t
    >> 
    >> Thereʼs one stray \342 in there, but the rest looks like ASCII. The
    >> character gnus should be trying to insert is #x2713, which is
    >> represented as #xE2 #x9C #x93 (\342 \234 \223), so it looks like there
    >> are some bytes missing.

    Eli> Where's the gap start address? are you sure \342 is not inside the
    Eli> gap?

gpt and gpt_byte are both 439 and that \342 is at byte pos 435

    Eli> Does Gnus make the buffer unibyte and then multibyte again or
    Eli> something?  Or maybe it uses some trick to replace a character in a
    Eli> string, when it inserts the tickmark, and that trick doesn't work with
    Eli> non-ASCII characters?

Hmm:

(defun gnus-summary-update-mark (mark type)
  (let ((forward (cdr (assq type gnus-summary-mark-positions)))
	(inhibit-read-only t))
    (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
    (when forward
      (when (looking-at "\r")
	(cl-incf forward))
      (when (<= (+ forward (point)) (point-max))
	;; Go to the right position on the line.
	(goto-char (+ forward (point)))
	;; Replace the old mark with the new mark.
        (let ((to-insert
               (subst-char-in-string
		(char-after) mark
		(buffer-substring (point) (1+ (point))))))
          (delete-region (point) (1+ (point)))
          (insert to-insert))

If in an emacs in *scratch* I do

(insert (subst-char-in-string (char-after) ?✓
    (buffer-substring-no-properties (point) (1+ (point)))))

that emacs displays several ^@ characters at the end of the buffer,
and then crashes the same way as with Gnus.

Perhaps Iʼm missing something, but isnʼt this just

(delete-region (point) (1+ (point)))
(insert mark)

(that seems to fix the gnus crash for me)

Robert