follow case:

(let ((str "#define SLOGE(...)\n ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG,\n __VA_ARGS__))"))
(with-temp-buffer
(delay-mode-hooks (funcall 'c++-mode))
(insert str)
(font-lock-ensure)
(buffer-string)
)
)

execute up code, emacs will hang


In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.18.9)
of 2018-12-18 built on xhyang-ThinkPad-T470p
Repository revision: 1691a51094d35ac4b2c311fa407c6b77eea7a105
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description: Ubuntu 16.04.3 LTS

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Mark set
#("#define SLOGE(...)
((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG,
__VA_ARGS__))" 0 1 (c-is-sws t c-in-sws t) 1 7 (c-in-sws t) 7 8 (c-in-sws t) 8 13 (c-in-sws t) 13 19 (c-in-sws t) 19 21 (c-in-sws t c-is-sws t) 21 22 (c-is-sws t))
next-line: End of buffer

Configured using:
'configure --enable-link-time-optimization --without-pop
--without-kerberos --without-kerberos5 --without-hesiod
--with-sound=alsa --with-x-toolkit=gtk3 --with-xpm --with-jpeg
--with-tiff --with-gif --with-png --with-rsvg --with-xml2
--with-imagemagick --with-xft --without-libotf --without-xim
--with-xaw3d --with-dbus --without-gconf --without-gsettings
--without-selinux --with-gnutls --with-zlib --with-modules
--with-file-notification=inotify --without-makeinfo --with-x
--exec-prefix=/usr/'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GLIB NOTIFY
INOTIFY GNUTLS LIBXML2 FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11
XDBE XIM MODULES THREADS LCMS2 GMP

Important settings:
value of $LC_MONETARY: zh_CN.UTF-8
value of $LC_NUMERIC: zh_CN.UTF-8
value of $LC_TIME: zh_CN.UTF-8
value of $LANG: en_US.UTF-8
value of $XMODIFIERS: @im=fcitx
locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny seq byte-opt gv
bytecomp byte-compile cconv dired dired-loaddefs format-spec rfc822 mml
mml-sec password-cache epa derived epg epg-config gnus-util rmail
rmail-loaddefs time-date mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils cc-mode cc-fonts easymenu
cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
cl-loaddefs cl-lib elec-pair mule-util tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads dbusbind inotify lcms2 dynamic-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 114827 9593)
(symbols 48 22507 1)
(strings 32 34433 2178)
(string-bytes 1 1049070)
(vectors 16 16742)
(vector-slots 8 532827 13806)
(floats 8 49 68)
(intervals 56 261 1)
(buffers 992 11)
(heap 1024 38686 1099))