Subject: bug#41957: 27.0.91; overlay-put freeze with auto-composition-mode ligatures

From: "James N. V. Cash" <[email-masked]>
Date: Fri, 19 Jun 2020 17:05:30 -0400

It seems that when putting the after-string property to an overlay, if
auto-composition-mode is enabled and the string contains a ligature,
Emacs freezes in overlay-put.

The below code freezes when starting with emacs -Q:

    (auto-composition-mode)
    (set-char-table-range composition-function-table ?= `(["=>" 0 compose-gstring-for-graphic]))
    (let ((o (make-overlay (point-min) (+ (point-min) 3) (current-buffer))))
      (overlay-put o 'after-string "=>"))

If auto-composition-mode is disabled or the string doesn't contain any ligatures, it works as expected.

Additionally, if I create the overlay then enable auto-composition-mode afterwards, it then freezes.

In GNU Emacs 27.0.91 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.22.30, cairo version 1.15.10)
 of 2020-06-17 built on gonk
Repository revision: c36c5a3dedbb2e0349be1b6c3b7567ea7b594f1c
Repository branch: HEAD
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description: Ubuntu 18.04.4 LTS

Configured using:
 'configure --with-xwidgets --with-cairo'

Configured features:
XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY
INOTIFY GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS XWIDGETS
LIBSYSTEMD JSON PDUMPER LCMS2 GMP

Important settings:
  value of $LANG: en_CA.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Memory information:
((conses 16 2130544 1191815)
 (symbols 48 73065 806)
 (strings 32 1403710 33264)
 (string-bytes 1 60271301)
 (vectors 16 387820)
 (vector-slots 8 5073825 225022)
 (floats 8 91573 10867)
 (intervals 56 39918 6792)
 (buffers 1000 121))