bug#47191: 28.0.50; Native compilation branch freeze in cc-mode

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

bug#47191: 28.0.50; Native compilation branch freeze in cc-mode

Damien Merenne
Using the native compilation branch, Create tmp.cpp with this:

```
// In state_machine
private: auto
state_machine::stop_bbbbbbb(states::recording &&s,
aaaaaa::bbbbbbb_stopped_reason reason)
-> fsm::state_machine<
aaaaaa::bbbbbbb::state_machine,
std::variant<aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_connected,
aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_disconnected,
aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_state,
aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_info,
aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_battery,
aaaaa::bbbb::cccccc::ddddddd::eeeeee::account_error,
aaaaa::bbbb::cccccc::ddddddd::eeeeee::account_valid>,
std::variant<aaaaa::bbbb::aaaaaa::bbbbbbb::states::init>>::state
```

Open using `emacs -Q tmp.cpp` and emacs freezes.

I managed to get some backtrace using `kill -USR2`:

* #f(compiled-function () #<bytecode 0xb89cd227791443a>)()
font-lock-default-fontify-region(35 597 nil)
c-font-lock-fontify-region(48 548 nil)
font-lock-fontify-region(48 548)
#f(compiled-function (fun) #<bytecode 0x1f23231d0aa2fbbe>)(font-lock-fontify-region)
run-hook-wrapped(#f(compiled-function (fun) #<bytecode 0x1f23231d0aa2fbbe>) font-lock-fontify-region)
jit-lock--run-functions(48 548)
jit-lock-fontify-now(48 548)
jit-lock-function(48)
redisplay_internal\ \(C\ function\)()

but at that point emacs is nearly unusable.

In GNU Emacs 28.0.50 (build 8, x86_64-pc-linux-gnu, GTK+ Version 3.24.23, cairo version 1.16.0)
of 2021-03-16 built on workstation.lan
Repository revision: f3abb1711811f43d1504d8e48f0d27e015b46d6c
Repository branch: feature/native-comp
Windowing system distributor 'The X.Org Foundation', version 11.0.12009000
System Description: Ubuntu 20.10

Configured using:
'configure --with-nativecomp --with-mailutils --with-pgtk --with-gnutls
--with-modules --with-json --without-gpm --with-file-notification=yes
--with-xwidgets --without-selinux --with-libsystemd CC=gcc-10'

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

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

Major mode: Magit

Minor modes in effect:
bloom-global-minor-mode: t
global-company-mode: t
company-mode: t
magit-wip-after-apply-mode: t
global-git-commit-mode: t
magit-auto-revert-mode: t
pdf-occur-global-minor-mode: t
yas-global-mode: t
yas-minor-mode: t
smartparens-global-mode: t
show-paren-mode: t
marginalia-mode: t
selectrum-prescient-mode: t
prescient-persist-mode: t
global-ligature-mode: t
ligature-mode: t
shell-dirtrack-mode: t
envrc-global-mode: t
envrc-mode: t
bepo-global-mode: t
which-key-mode: t
savehist-mode: t
Info-breadcrumbs-in-mode-line-mode: t
override-global-mode: t
selectrum-mode: t
tooltip-mode: t
global-eldoc-mode: t
electric-indent-mode: t
mouse-wheel-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
buffer-read-only: t
line-number-mode: t
transient-mark-mode: t

Load-path shadows:
~/.emacs.d/pkg/bloomlife/aio-let hides ~/.emacs.d/pkg/jiracs/aio-let
~/.emacs.d/pkg/dash-docs/dash-docs hides /home/dam/.emacs.d/var/elpa/dash-docs-20200516.1943/dash-docs
~/.emacs.d/pkg/use-package/use-package-ensure-system-package hides /home/dam/.emacs.d/var/elpa/use-package-ensure-system-package-20180913.1501/use-package-ensure-system-package
~/.emacs.d/pkg/use-package/use-package-ensure hides /home/dam/.emacs.d/var/elpa/use-package-20210207.1926/use-package-ensure
~/.emacs.d/pkg/use-package/use-package hides /home/dam/.emacs.d/var/elpa/use-package-20210207.1926/use-package
~/.emacs.d/pkg/use-package/use-package-bind-key hides /home/dam/.emacs.d/var/elpa/use-package-20210207.1926/use-package-bind-key
~/.emacs.d/pkg/use-package/use-package-lint hides /home/dam/.emacs.d/var/elpa/use-package-20210207.1926/use-package-lint
~/.emacs.d/pkg/use-package/use-package-diminish hides /home/dam/.emacs.d/var/elpa/use-package-20210207.1926/use-package-diminish
~/.emacs.d/pkg/use-package/use-package-delight hides /home/dam/.emacs.d/var/elpa/use-package-20210207.1926/use-package-delight
~/.emacs.d/pkg/use-package/use-package-jump hides /home/dam/.emacs.d/var/elpa/use-package-20210207.1926/use-package-jump
~/.emacs.d/pkg/use-package/use-package-core hides /home/dam/.emacs.d/var/elpa/use-package-20210207.1926/use-package-core
~/.emacs.d/pkg/use-package/bind-key hides /home/dam/.emacs.d/var/elpa/bind-key-20210210.1609/bind-key

Features:
(shadow sort mail-extr emacsbug sendmail mule-util face-remap vc-mtn
vc-hg vc-bzr vc-src vc-sccs vc-cvs vc-rcs vc checkdoc lisp-mnt form-feed
company-oddmuse company-keywords company-etags company-gtags
company-dabbrev-code company-dabbrev company-files company-clang
company-capf company-cmake company-semantic company-template
company-bbdb bloomlife bloom-mode eglot array jsonrpc ert ewoc debug
backtrace sonar circleci bitbucket bloom-sensor gdb-mi bloom-tools
bloom-org bloom-magit bloom-project bloom-test-runner bloom-common
bloom-build bloom-cmake bloom-conan bloom-bbw bloom-target bloom-pkg
atlassian atlassian-jira atlassian-common request jiracs json-bind
aio-let jiracs-mode jiracs-db jiracs-common aio company-terraform
company-terraform-data terraform-mode hcl-mode company racer
smartparens-rust rust-mode rubocop robe etags fileloop generator
inf-ruby rbenv ruby-mode smie smartparens-python python tramp-sh
smartparens-scala scala-mode scala-mode-prettify-symbols
scala-mode-imenu scala-mode-map scala-mode-fontlock scala-mode-indent
scala-mode-paragraph scala-mode-syntax scala-mode-lib java-imports
pcache eieio-base elisp-format flyspell test-runner-ert elfmt cask-mode
djinni-mode gud-lldb cmake-api test-runner-catch2 eldoc-cmake cmake-mode
smartparens-rst rst android pbuf gud xref forge-list forge-commands
forge-semi forge-bitbucket buck forge-gogs gogs forge-gitea gtea
forge-gitlab glab forge-github forge-notify forge-revnote forge-pullreq
forge-issue forge-topic bug-reference forge-post forge-repo forge
forge-core forge-db closql emacsql-sqlite emacsql emacsql-compiler
ghub-graphql treepy gsexp ghub url-http url-gw nsm url-auth magit-extras
magit-bookmark magit-submodule magit-obsolete magit-blame magit-stash
magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone
magit-remote magit-commit magit-sequence magit-notes magit-worktree
magit-tag magit-merge magit-branch magit-reset magit-files magit-refs
magit-status magit magit-repos magit-apply magit-wip magit-log
which-func magit-diff smerge-mode git-commit log-edit message rmc rfc822
mml mml-sec epa epg epg-config mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader pcvs-util add-log magit-core
magit-autorevert magit-margin magit-transient magit-process with-editor
server magit-mode magit-git magit-section magit-utils git-timemachine
transient vc-git diff-mode vc-dispatcher flymake-cursor flymake-proc
flymake warnings diff ispell reformatter test-runner ag vc-svn
find-dired dired-collapse dired-rainbow dired-narrow delsel dired-filter
f s dired-hacks-utils dired-x dired-aux plantuml-mode pdf-occur ibuf-ext
ibuffer ibuffer-loaddefs tablist tablist-filter semantic/wisent/comp
semantic/wisent semantic/wisent/wisent semantic/util-modes semantic/util
semantic semantic/tag semantic/lex semantic/fw mode-local find-func
cedet pdf-isearch let-alist pdf-misc imenu pdf-tools pdf-view jka-compr
pdf-cache pdf-info tq pdf-util xwwp eww xdg url-queue shr kinsoku svg
dom mm-url gnus nnheader gnus-util rmail rmail-loaddefs rfc2047 rfc2045
ietf-drums mail-utils mm-util mail-prsvr xwidget image-mode dired
dired-loaddefs exif bookmark smartparens-markdown markdown-mode noutline
outline yasnippet wgrep grep compile text-property-search cap-words
superword subword string-inflection smartparens-config smartparens-text
smartparens-c smartparens-ruby smartparens dash cc-mode cc-fonts
cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
paren mmm-mode mmm-univ mmm-class mmm-region mmm-auto mmm-vars mmm-utils
mmm-compat iedit iedit-lib autorevert filenotify marginalia project
selectrum-prescient selectrum minibuf-eldef crm prescient all-the-icons
all-the-icons-faces data-material data-weathericons data-octicons
data-fileicons data-faicons data-alltheicons ligature
solarized-dark-high-contrast-theme solarized-palettes solarized-theme
solarized solarized-faces color use-theme pcase tramp tramp-loaddefs
trampver tramp-integration files-x tramp-compat shell pcomplete comint
ring parse-time iso8601 time-date ls-lisp envrc inheritenv ansi-color
eshell esh-cmd esh-ext esh-opt esh-proc esh-io esh-arg esh-module
esh-groups esh-util bepo which-key time savehist recentf tree-widget
advice info+ exec-path-from-shell diminish dash-docs
use-package-dash-docs gnutls puny thingatpt format-spec xml async
no-littering use-package-ensure-system-package system-packages cl-extra
help-mode use-package use-package-ensure use-package-delight
use-package-diminish use-package-bind-key bind-key use-package-core
derived edmacro kmacro easy-mmode cl rx info cus-edit pp cus-start
cus-load wid-edit package browse-url url url-proxy url-privacy
url-expand url-methods url-history url-cookie url-domsuf url-util
mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core
cl-macs eieio-loaddefs password-cache json subr-x map url-vars seq
byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib iso-transl
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 tab-bar menu-bar rfn-eshadow isearch
easymenu timer select scroll-bar mouse jit-lock font-lock syntax
facemenu font-core term/tty-colors frame minibuffer 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
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads
xwidget-internal dbusbind inotify dynamic-setting system-font-setting
font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 705250 558960)
(symbols 48 45820 1)
(strings 32 175645 34938)
(string-bytes 1 6557321)
(vectors 16 76584)
(vector-slots 8 1715804 487208)
(floats 8 1183 1016)
(intervals 56 749 5)
(buffers 992 21))



Reply | Threaded
Open this post in threaded view
|

bug#47191: 28.0.50; Native compilation branch freeze in cc-mode

Emacs - Bugs mailing list
Damien <[hidden email]> writes:

> Using the native compilation branch, Create tmp.cpp with this:
>
> ```
> // In state_machine
> private: auto
> state_machine::stop_bbbbbbb(states::recording &&s,
> aaaaaa::bbbbbbb_stopped_reason reason)
> -> fsm::state_machine<
> aaaaaa::bbbbbbb::state_machine,
> std::variant<aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_connected,
> aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_disconnected,
> aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_state,
> aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_info,
> aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_battery,
> aaaaa::bbbb::cccccc::ddddddd::eeeeee::account_error,
> aaaaa::bbbb::cccccc::ddddddd::eeeeee::account_valid>,
> std::variant<aaaaa::bbbb::aaaaaa::bbbbbbb::states::init>>::state
> ```
>
> Open using `emacs -Q tmp.cpp` and emacs freezes.

I've just compiled f3abb17118 but I can't reproduce this.

I'm seeing you are compiling with '--with-nativecomp', we have changed
the flag into '--with-nativecompilation' (yeah sorry) so native
compilation is disable on your build (should be also listed in
"Configured features:" if enabled).

Rebuilding f3abb17118 without enabling native compilation I still can't
reproduce this :(

Thanks

  Andrea



Reply | Threaded
Open this post in threaded view
|

bug#47191: 28.0.50; Native compilation branch freeze in cc-mode

Damien Merenne
Hello,


Thank you for your response, I'll try again with the same commit and the right configuration flag :)


Damien


"Andrea Corallo" [hidden email] – 16 mars 2021 16:35

> Damien <[hidden email]> writes:
>
> > Using the native compilation branch, Create tmp.cpp with this:
> >
> > ```
> > // In state_machine
> > private: auto
> > state_machine::stop_bbbbbbb(states::recording &&s,
> > aaaaaa::bbbbbbb_stopped_reason reason)
> > -> fsm::state_machine<
> > aaaaaa::bbbbbbb::state_machine,
> > std::variant<aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_connected,
> > aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_disconnected,
> > aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_state,
> > aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_info,
> > aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_battery,
> > aaaaa::bbbb::cccccc::ddddddd::eeeeee::account_error,
> > aaaaa::bbbb::cccccc::ddddddd::eeeeee::account_valid>,
> > std::variant<aaaaa::bbbb::aaaaaa::bbbbbbb::states::init>>::state
> > ```
> >
> > Open using `emacs -Q tmp.cpp` and emacs freezes.
>
> I've just compiled f3abb17118 but I can't reproduce this.
>
> I'm seeing you are compiling with '--with-nativecomp', we have changed
> the flag into '--with-nativecompilation' (yeah sorry) so native
> compilation is disable on your build (should be also listed in
> "Configured features:" if enabled).
>
> Rebuilding f3abb17118 without enabling native compilation I still can't
> reproduce this :(
>
> Thanks
>
> Andrea
>
>



Reply | Threaded
Open this post in threaded view
|

bug#47191: 28.0.50; Native compilation branch freeze in cc-mode

Damien Merenne
In reply to this post by Emacs - Bugs mailing list
So I just tested again, with recompiling with `--with-nativecompilation` and I have the exact same behavior. So maybe it is not linked to the compilation branch then. I'll try to reproduce it this weekend on master and maybe bisect it.


"Andrea Corallo" [hidden email] – 16 mars 2021 16:35

> Damien <[hidden email]> writes:
>
> > Using the native compilation branch, Create tmp.cpp with this:
> >
> > ```
> > // In state_machine
> > private: auto
> > state_machine::stop_bbbbbbb(states::recording &&s,
> > aaaaaa::bbbbbbb_stopped_reason reason)
> > -> fsm::state_machine<
> > aaaaaa::bbbbbbb::state_machine,
> > std::variant<aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_connected,
> > aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_disconnected,
> > aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_state,
> > aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_info,
> > aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_battery,
> > aaaaa::bbbb::cccccc::ddddddd::eeeeee::account_error,
> > aaaaa::bbbb::cccccc::ddddddd::eeeeee::account_valid>,
> > std::variant<aaaaa::bbbb::aaaaaa::bbbbbbb::states::init>>::state
> > ```
> >
> > Open using `emacs -Q tmp.cpp` and emacs freezes.
>
> I've just compiled f3abb17118 but I can't reproduce this.
>
> I'm seeing you are compiling with '--with-nativecomp', we have changed
> the flag into '--with-nativecompilation' (yeah sorry) so native
> compilation is disable on your build (should be also listed in
> "Configured features:" if enabled).
>
> Rebuilding f3abb17118 without enabling native compilation I still can't
> reproduce this :(
>
> Thanks
>
> Andrea
>
>



Reply | Threaded
Open this post in threaded view
|

bug#47191: File as attachment

Damien Merenne
In reply to this post by Damien Merenne
Also here is the file as attachment to make sure it was not a copy/paste error

tmp.cpp (832 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#47191: File as attachment

Alan Mackenzie
Hello, Eli and Damien.

On Fri, Mar 19, 2021 at 17:28:03 +0200, Eli Zaretskii wrote:
> > From: Damien <[hidden email]>
> > Date: Wed, 17 Mar 2021 07:48:39 +0000

> > Also here is the file as attachment to make sure it was not a copy/paste error

> Thanks.

> Emacs infloops in redisplay when visiting this file, because
> fontification of this file infloops, and that happens on the master
> branch as well, so it has nothing to do with native-compilation
> branch.  The infloop seems to be in c-forward-name, I attach the
> backtrace below.

> Alan, could you please look into this?

[ .... ]

>   Lisp Backtrace:
>   "c-forward-name" (0x8234a0)
>   "c-forward-type" (0x823e30)
>   "c-forward-decl-or-cast-1" (0x825240)
>   0x6d7e6e0 PVEC_COMPILED
>   "c-find-decl-spots" (0x826d30)
>   "c-font-lock-declarations" (0x8273c8)
>   "font-lock-fontify-keywords-region" (0x827b40)
>   "font-lock-default-fontify-region" (0x828190)
>   "c-font-lock-fontify-region" (0x828808)
>   "font-lock-fontify-region" (0x828dc8)
>   0x6fdbd30 PVEC_COMPILED
>   "run-hook-wrapped" (0x829690)
>   "jit-lock--run-functions" (0x829cc0)
>   "jit-lock-fontify-now" (0x82a3e8)
>   "jit-lock-function" (0x82aa68)
>   "redisplay_internal (C function)" (0x0)

The trigger for the bug was a CC Mode "name" (the return type) which was
longer than 500 characters.  This 500 was a search limit introduced for
performance reasons around the turn of the year.  Part of the bug was
that when a forward scanning macro (c-forward-syntactic-ws) was given a
limit less than point, point was set back to that limit, causing the
loop.

The fix involves not ever moving point backwards in
c-forward-syntactic-ws, and recalculating the 500 character limit after
scanning a template construct; template expressions can easily be very
long.

Damien, would you please try out the following patch (the files are in
..../emacs/lisp/progmodes) on your real C++ source code, and either
confirm to us that the bug is fixed, or tell us what still needs fixing.
After applying the patch, please recompile _all_ of CC Mode (the files
..../emacs/progmodes/cc-*.el), since two macros have been amended.  If
you want any help with the patching or byte compiling, feel free to send
me private mail.  Thanks!

Here's the patch:



diff -r 11350de71bc6 cc-defs.el
--- a/cc-defs.el Sat Mar 06 15:11:24 2021 +0000
+++ b/cc-defs.el Sat Mar 20 20:08:58 2021 +0000
@@ -656,14 +656,16 @@
 
 LIMIT sets an upper limit of the forward movement, if specified.  If
 LIMIT or the end of the buffer is reached inside a comment or
-preprocessor directive, the point will be left there.
+preprocessor directive, the point will be left there.  If point starts
+on the wrong side of LIMIT, it stays unchanged.
 
 Note that this function might do hidden buffer changes.  See the
 comment at the start of cc-engine.el for more info."
   (if limit
-      `(save-restriction
- (narrow-to-region (point-min) (or ,limit (point-max)))
- (c-forward-sws))
+      `(when (< (point) (or ,limit (point-max)))
+ (save-restriction
+   (narrow-to-region (point-min) (or ,limit (point-max)))
+   (c-forward-sws)))
     '(c-forward-sws)))
 
 (defmacro c-backward-syntactic-ws (&optional limit)
@@ -675,14 +677,16 @@
 
 LIMIT sets a lower limit of the backward movement, if specified.  If
 LIMIT is reached inside a line comment or preprocessor directive then
-the point is moved into it past the whitespace at the end.
+the point is moved into it past the whitespace at the end.  If point
+starts on the wrong side of LIMIT, it stays unchanged.
 
 Note that this function might do hidden buffer changes.  See the
 comment at the start of cc-engine.el for more info."
   (if limit
-      `(save-restriction
- (narrow-to-region (or ,limit (point-min)) (point-max))
- (c-backward-sws))
+      `(when (> (point) (or ,limit (point-min)))
+ (save-restriction
+   (narrow-to-region (or ,limit (point-min)) (point-max))
+   (c-backward-sws)))
     '(c-backward-sws)))
 
 (defmacro c-forward-sexp (&optional count)
diff -r 11350de71bc6 cc-engine.el
--- a/cc-engine.el Sat Mar 06 15:11:24 2021 +0000
+++ b/cc-engine.el Sat Mar 20 20:08:58 2021 +0000
@@ -8318,7 +8318,7 @@
   ;; o - nil if no name is found;
   ;; o - 'template if it's an identifier ending with an angle bracket
   ;;   arglist;
-  ;; o - 'operator of it's an operator identifier;
+  ;; o - 'operator if it's an operator identifier;
   ;; o - t if it's some other kind of name.
   ;;
   ;; This function records identifier ranges on
@@ -8338,6 +8338,7 @@
  (lim+ (c-determine-+ve-limit 500)))
     (while
  (and
+ (< (point) lim+)
  (looking-at c-identifier-key)
 
  (progn
@@ -8387,23 +8388,28 @@
   ;; '*', '&' or a name followed by ":: *",
   ;; where each can be followed by a sequence
   ;; of `c-opt-type-modifier-key'.
-  (while (cond ((looking-at "[*&]")
- (goto-char (match-end 0))
- t)
-       ((looking-at c-identifier-start)
- (and (c-forward-name)
-     (looking-at "::")
-     (progn
-       (goto-char (match-end 0))
-       (c-forward-syntactic-ws lim+)
-       (eq (char-after) ?*))
-     (progn
-       (forward-char)
-       t))))
+  (while
+      (and
+       (< (point) lim+)
+       (cond ((looking-at "[*&]")
+      (goto-char (match-end 0))
+      t)
+     ((looking-at c-identifier-start)
+      (and (c-forward-name)
+   (looking-at "::")
+   (progn
+     (goto-char (match-end 0))
+     (c-forward-syntactic-ws lim+)
+     (eq (char-after) ?*))
+   (progn
+     (forward-char)
+     t)))))
     (while (progn
      (c-forward-syntactic-ws lim+)
      (setq pos (point))
-     (looking-at c-opt-type-modifier-key))
+     (and
+      (<= (point) lim+)
+      (looking-at c-opt-type-modifier-key)))
       (goto-char (match-end 1))))))
 
        ((looking-at c-overloadable-operators-regexp)
@@ -8449,6 +8455,9 @@
        ;; Maybe an angle bracket arglist.
        (when (let (c-last-identifier-range)
        (c-forward-<>-arglist nil))
+ ;; <> arglists can legitimately be very long, so recalculate
+ ;; `lim+'.
+ (setq lim+ (c-determine-+ve-limit 500))
 
  (c-forward-syntactic-ws lim+)
  (unless (eq (char-after) ?\()


--
Alan Mackenzie (Nuremberg, Germany).



Reply | Threaded
Open this post in threaded view
|

bug#47191: 28.0.50; Native compilation branch freeze in cc-mode

Daniel Colascione-5
In reply to this post by Damien Merenne
On 3/17/21 3:47 AM, Damien wrote:

> So I just tested again, with recompiling with `--with-nativecompilation` and I have the exact same behavior. So maybe it is not linked to the compilation branch then. I'll try to reproduce it this weekend on master and maybe bisect it.

The following program freezes in Emacs -Q on current master. To repro,
start with emacs -Q bad-cc-mode.cpp and scroll down

> "Andrea Corallo" [hidden email] – 16 mars 2021 16:35
>> Damien <[hidden email]> writes:
>>
>>> Using the native compilation branch, Create tmp.cpp with this:
>>>
>>> ```
>>> // In state_machine
>>> private: auto
>>> state_machine::stop_bbbbbbb(states::recording &&s,
>>> aaaaaa::bbbbbbb_stopped_reason reason)
>>> -> fsm::state_machine<
>>> aaaaaa::bbbbbbb::state_machine,
>>> std::variant<aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_connected,
>>> aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_disconnected,
>>> aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_state,
>>> aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_info,
>>> aaaaa::bbbb::cccccc::ddddddd::eeeeee::aaaaaa_battery,
>>> aaaaa::bbbb::cccccc::ddddddd::eeeeee::account_error,
>>> aaaaa::bbbb::cccccc::ddddddd::eeeeee::account_valid>,
>>> std::variant<aaaaa::bbbb::aaaaaa::bbbbbbb::states::init>>::state
>>> ```
>>>
>>> Open using `emacs -Q tmp.cpp` and emacs freezes.
>> I've just compiled f3abb17118 but I can't reproduce this.
>>
>> I'm seeing you are compiling with '--with-nativecomp', we have changed
>> the flag into '--with-nativecompilation' (yeah sorry) so native
>> compilation is disable on your build (should be also listed in
>> "Configured features:" if enabled).
>>
>> Rebuilding f3abb17118 without enabling native compilation I still can't
>> reproduce this :(
>>
>> Thanks
>>
>> Andrea
>>
>>
>
>

bad-cc-mode.cpp (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

bug#47191: File as attachment

Alan Mackenzie
In reply to this post by Alan Mackenzie
Hello, Damien.

On Mon, Mar 29, 2021 at 09:12:32 +0000, Damien wrote:
> The patch fixes the problem for me. Also, before the patch emacs would
> freeze regularly due to eglot formatting the cpp function definintions
> when moving past one, and everything seems ok now.

That's great!  Thanks for doing the testing.

> Thanks a lot for helping me and fixing this !

I've committed the fix to all the appropriate places, in particular to
the Emacs master branch at savannah.  I'm closing the bug with this post.

--
Alan Mackenzie (Nuremberg, Germany).