From unknown Sun Jun 22 00:15:17 2025 X-Loop: help-debbugs@gnu.org Subject: bug#74738: 31.0.50; Freezes in Python-mode on some Python file when searching or scrolling Resent-From: rehan malak Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 08 Dec 2024 15:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 74738 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 74738@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.173367000722874 (code B ref -1); Sun, 08 Dec 2024 15:01:02 +0000 Received: (at submit) by debbugs.gnu.org; 8 Dec 2024 15:00:07 +0000 Received: from localhost ([127.0.0.1]:51369 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKIlQ-0005ve-Ei for submit@debbugs.gnu.org; Sun, 08 Dec 2024 10:00:07 -0500 Received: from lists.gnu.org ([209.51.188.17]:55866) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKGzN-0008Rx-Tc for submit@debbugs.gnu.org; Sun, 08 Dec 2024 08:06:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tKGxF-0007o6-S9 for bug-gnu-emacs@gnu.org; Sun, 08 Dec 2024 08:04:11 -0500 Received: from mail-vk1-xa2f.google.com ([2607:f8b0:4864:20::a2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tKGxD-0002wR-8c for bug-gnu-emacs@gnu.org; Sun, 08 Dec 2024 08:04:09 -0500 Received: by mail-vk1-xa2f.google.com with SMTP id 71dfb90a1353d-5160f1870f3so385862e0c.0 for ; Sun, 08 Dec 2024 05:04:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733663045; x=1734267845; darn=gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=G2sIsTZFehvl/4crpyGcbdxxJ9krPBKlCTxOM3RzpVE=; b=cRUsyagGJgR0ZWxBrMXe1bwJM7gfweIsvmQdtM0eoKVrf3qDBY+CDVP6H4iqYBMLHO auJ2PkGsWYe8gwfxqvNPX320sP/0dTRMD3O70rgTvt9wia6nrkMUJ6zrWYP4wxU86S43 nSdrxiOL83tVPQZxK9Bmqoe+uw2ybtnA4pc6F/VxnCX1YdwTSLlDnzx4WQ2NYcWx+FkE LpsmveNPs/S63Uq8W+ovlpsGy4VQG9M9x9gJeSACc2WfxPUkRVaVD324yK0ivqf4S2xb aK1q7HJmqHq4WHaubDyodLo/YTiO+oCbcU7LpsLFOZ2WkP5yKZT38sepLk9Brgk6BN0G fqLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733663045; x=1734267845; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=G2sIsTZFehvl/4crpyGcbdxxJ9krPBKlCTxOM3RzpVE=; b=AvxNlc6gtOSJWJcOnBvQU2dAJj84Xd+ad/3Cn1YZE6RFPjtPPr6QJta9l3dzNV8Par Hq/16g25l4ZOCDkkL5rYBFxwH+Fswc9DhS1QGuOZW6KLhpZtCl/CYEkujgCuB1LrmdC+ 2B52VXy7D/D1VojQbr5/AITLGv6lijTFj7338U3iYlsZ4A+b0ZGXQD+2D6ajItErdP4C 1LAuj+0hsUe0h/AvrLgD4TMXeyp0tJMZ8Xlre5qDV4v9hYB1FE1LI856JO0+J4kjuW13 UKot3Bs0aCJp8xvvZzS8XyJ9HirVrFYPse6aXnsjstCNyv+DuzDkYFZgLcN3bOeC+k9y +FFw== X-Gm-Message-State: AOJu0YwV+Gr+2/qmopWsEBMvdfWIT/lO1x5PJAO9viRt3dABxZff3uKh g8nIMBZCsnyrDDN9hmfGdKPwo7U7pdfLnFZT5TsLoSRcdHwzE3hJobu+r4o2mSOoTCyndKOOcX+ Km9oGAgRojo3Qjc7ZNg9gcD57BjNEavWn X-Gm-Gg: ASbGnctSLHZp56F+jDPgSDZ4zKhw7ixEgjqsfggAPXdTqa7OGv5AH+WKQ+N0qGe0dBf q+6kM9P9LgdlbBT6PVKvY0P/eX0WPWdgx X-Google-Smtp-Source: AGHT+IFQqvyrjZxv5CvdhZeTPdJL6yayeZhrpC6zGfXF+1maYVnEOzErf9IU9Za91zJoDw10g2f9u1D09hArNs8R2rc= X-Received: by 2002:a05:6122:c81:b0:515:3bfb:d421 with SMTP id 71dfb90a1353d-515fca3498amr8011815e0c.6.1733663044861; Sun, 08 Dec 2024 05:04:04 -0800 (PST) MIME-Version: 1.0 From: rehan malak Date: Sun, 8 Dec 2024 14:05:36 +0100 Message-ID: Content-Type: multipart/alternative; boundary="000000000000f308ff0628c1e1b6" Received-SPF: pass client-ip=2607:f8b0:4864:20::a2f; envelope-from=rehan.malak@gmail.com; helo=mail-vk1-xa2f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -0.6 (/) X-Mailman-Approved-At: Sun, 08 Dec 2024 10:00:02 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.6 (-) --000000000000f308ff0628c1e1b6 Content-Type: text/plain; charset="UTF-8" Hi, I can reproduce systematically this freeze dealing with a 10000lines Python file : wget https://raw.githubusercontent.com/hugsy/gef/refs/heads/main/gef.py emacs -Q gef.py PageDown several times or scrolling with the mouse Emacs freezes, Ctrl-g not working, CPU 100% It works also by searching : Ctrl-s show RET then Ctrl-s several times With a minimal .emacs : (set debug-on-error t) (set debug-on-quit t) and before scrolling M-x profiler-start RET then in an external terminal pkill -SIGUSR2 emacs I get the backtrace : Debugger entered--entering a function: * #f(compiled-function () #)() syntax-ppss() python-syntax-context-type() python-nav-forward-block(-1) python-nav-backward-block() python-nav-beginning-of-block() python-nav-end-of-block() python-info-statement-ends-block-p() python-info-end-of-block-p() python-nav--forward-sexp(1 nil nil) python-nav-forward-sexp(1) forward-sexp(1) up-list(1) python--font-lock-f-strings(30419) font-lock-fontify-keywords-region(28914 30419 nil) font-lock-default-fontify-region(28914 30414 nil) font-lock-fontify-region(28914 30414) #f(compiled-function (fun) #)(font-lock-fontify-region) run-hook-wrapped(#f(compiled-function (fun) #) font-lock-fontify-region) jit-lock--run-functions(28914 30414) jit-lock-fontify-now(28914 30414) jit-lock-function(28914) and can look at profiler report M-x profiler-stop M-x profiler-report showing time spent in syntax-ppss 17770 88% - jit-lock-function 17770 88% - jit-lock-fontify-now 17770 88% - jit-lock--run-functions 17770 88% - run-hook-wrapped 17770 88% - # 17770 88% - font-lock-fontify-region 17770 88% - font-lock-default-fontify-region 17690 87% - font-lock-fontify-keywords-region 17678 87% - python--font-lock-f-strings 17674 87% - up-list 17674 87% - forward-sexp 17674 87% - python-nav-forward-sexp 17674 87% - python-nav--forward-sexp 9253 45% - python-info-end-of-block-p 9245 45% - python-info-statement-ends-block-p 9221 45% - python-nav-end-of-block 8609 42% - python-nav-beginning-of-block 8557 42% - python-nav-backward-block 8557 42% - python-nav-forward-block 8005 39% - python-syntax-context-type 7997 39% - syntax-ppss 7097 35% parse-partial-sexp 753 3% + # 376 1% + python-nav-beginning-of-statement 132 0% re-search-backward 24 0% looking-at 28 0% current-indentation 8 0% + python-nav-beginning-of-statement 4 0% python-info-current-line-empty-p 4 0% + python-info-current-line-comment-p 604 2% + python-nav-end-of-statement 4 0% + python-info-current-line-comment-p 4 0% current-indentation 24 0% + python-nav-end-of-statement 8 0% + python-info-end-of-statement-p 8178 40% - python-info-statement-ends-block-p 8150 40% - python-nav-end-of-block 7754 38% - python-nav-beginning-of-block 7738 38% - python-nav-backward-block 7734 38% - python-nav-forward-block 7178 35% - python-syntax-context-type 7174 35% - syntax-ppss 6978 34% parse-partial-sexp 8 0% make-closure 8 0% # 4 0% syntax-table 4 0% syntax-ppss--update-stats 412 2% + python-nav-beginning-of-statement 92 0% re-search-backward 44 0% looking-at 12 0% current-indentation 4 0% looking-at 380 1% + python-nav-end-of-statement 16 0% + python-util-forward-comment 28 0% + python-nav-end-of-statement 151 0% + python-nav-end-of-block 28 0% + python-info-beginning-of-block-p 24 0% + python-info-end-of-statement-p 20 0% + python-info-beginning-of-statement-p 8 0% + python-syntax-context-type 8 0% + python-info-statement-starts-block-p 4 0% + syntax-ppss 8 0% + # 4 0% + # 80 0% + font-lock-fontify-syntactically-region 2279 11% Automatic GC 73 0% + redisplay_internal (C function) 40 0% + command-execute 8 0% + ... 4 0% + mouse--click-1-maybe-follows-link other people talking about python/profiling/syntax-ppss : https://www.reddit.com/r/emacs/comments/z0oye9/emacs_freezes_when_opening_a_python_file/ https://www.reddit.com/r/emacs/comments/9h7onq/large_python_files_hanging_with_an_unmatched_quote/ Please tell me how I can help ? Please tell me if there is a workaround without losing python syntax color ? Thanks Rehan In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.43, cairo version 1.18.2) of 2024-12-08 built on cndl Repository revision: b953bcb17047998c9e41cede7c5e5ffec22209b2 Repository branch: master System Description: Debian GNU/Linux trixie/sid Configured using: 'configure --prefix=/home/jean/local/emacs --with-pgtk' Configured features: CAIRO DBUS FREETYPE GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PGTK PNG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS WEBP XIM GTK3 ZLIB Important settings: value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: Python Minor modes in effect: tooltip-mode: t global-eldoc-mode: t eldoc-mode: t show-paren-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 minibuffer-regexp-mode: t line-number-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message mailcap yank-media puny dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068 epg-config gnus-util text-property-search 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 cl-seq python rx project byte-opt gv bytecomp byte-compile compat pcase treesit comint subr-x ansi-osc ring cl-loaddefs cl-lib ansi-color rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/pgtk-win pgtk-win term/common-win touch-screen pgtk-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-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 font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic indonesian philippine 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 emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads dbusbind inotify dynamic-setting system-font-setting font-render-setting cairo gtk pgtk multi-tty move-toolbar make-network-process emacs) Memory information: ((conses 16 60995 13527) (symbols 48 7517 0) (strings 32 19122 1493) (string-bytes 1 515162) (vectors 16 13554) (vector-slots 8 145472 8433) (floats 8 26 2) (intervals 56 436 0) (buffers 984 12)) --000000000000f308ff0628c1e1b6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,
I can reproduce systematically this freeze dealing = with a 10000lines
Python file :

wget https://raw.githubuserco= ntent.com/hugsy/gef/refs/heads/main/gef.py
emacs -Q gef.py

Pa= geDown several times or scrolling with the mouse

Emacs freezes, Ctrl= -g not working, CPU 100%

It works also by searching : Ctrl-s show RE= T
then Ctrl-s several times




With a minimal .emacs :
(set debug-on-error t)
(set debug-on-quit t)

and before s= crolling

M-x profiler-start RET

then in an external terminal<= br>
pkill -SIGUSR2 emacs

I get the backtrace :

Debugger en= tered--entering a function:
* #f(compiled-function () #<bytecode -0x1= 79dcd1db31182ae>)()
=C2=A0 syntax-ppss()
=C2=A0 python-syntax-cont= ext-type()
=C2=A0 python-nav-forward-block(-1)
=C2=A0 python-nav-back= ward-block()
=C2=A0 python-nav-beginning-of-block()
=C2=A0 python-nav= -end-of-block()
=C2=A0 python-info-statement-ends-block-p()
=C2=A0 py= thon-info-end-of-block-p()
=C2=A0 python-nav--forward-sexp(1 nil nil)=C2=A0 python-nav-forward-sexp(1)
=C2=A0 forward-sexp(1)
=C2=A0 up-l= ist(1)
=C2=A0 python--font-lock-f-strings(30419)
=C2=A0 font-lock-fon= tify-keywords-region(28914 30419 nil)
=C2=A0 font-lock-default-fontify-r= egion(28914 30414 nil)
=C2=A0 font-lock-fontify-region(28914 30414)
= =C2=A0 #f(compiled-function (fun) #<bytecode -0x8a96d65e1315e71>)(fon= t-lock-fontify-region)
=C2=A0 run-hook-wrapped(#f(compiled-function (fun= ) #<bytecode -0x8a96d65e1315e71>) font-lock-fontify-region)
=C2=A0= jit-lock--run-functions(28914 30414)
=C2=A0 jit-lock-fontify-now(28914 = 30414)
=C2=A0 jit-lock-function(28914)

and can look at profiler r= eport

M-x profiler-stop
M-x profiler-report

showing time s= pent in syntax-ppss


=C2=A0 =C2=A0 =C2=A0 =C2=A017770 =C2=A088% -= jit-lock-function
=C2=A0 =C2=A0 =C2=A0 =C2=A017770 =C2=A088% =C2=A0- ji= t-lock-fontify-now
=C2=A0 =C2=A0 =C2=A0 =C2=A017770 =C2=A088% =C2=A0 - j= it-lock--run-functions
=C2=A0 =C2=A0 =C2=A0 =C2=A017770 =C2=A088% =C2=A0= =C2=A0- run-hook-wrapped
=C2=A0 =C2=A0 =C2=A0 =C2=A017770 =C2=A088% =C2= =A0 =C2=A0 - #<byte-code-function FA0>
=C2=A0 =C2=A0 =C2=A0 =C2=A0= 17770 =C2=A088% =C2=A0 =C2=A0 =C2=A0- font-lock-fontify-region
=C2=A0 = =C2=A0 =C2=A0 =C2=A017770 =C2=A088% =C2=A0 =C2=A0 =C2=A0 - font-lock-defaul= t-fontify-region
=C2=A0 =C2=A0 =C2=A0 =C2=A017690 =C2=A087% =C2=A0 =C2= =A0 =C2=A0 =C2=A0- font-lock-fontify-keywords-region
=C2=A0 =C2=A0 =C2= =A0 =C2=A017678 =C2=A087% =C2=A0 =C2=A0 =C2=A0 =C2=A0 - python--font-lock-f= -strings
=C2=A0 =C2=A0 =C2=A0 =C2=A017674 =C2=A087% =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0- up-list
=C2=A0 =C2=A0 =C2=A0 =C2=A017674 =C2=A087% =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 - forward-sexp
=C2=A0 =C2=A0 =C2=A0 =C2= =A017674 =C2=A087% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- python-nav-fo= rward-sexp
=C2=A0 =C2=A0 =C2=A0 =C2=A017674 =C2=A087% =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 - python-nav--forward-sexp
=C2=A0 =C2=A0 =C2=A0= =C2=A0 9253 =C2=A045% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- py= thon-info-end-of-block-p
=C2=A0 =C2=A0 =C2=A0 =C2=A0 9245 =C2=A045% =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 - python-info-statement-ends-= block-p
=C2=A0 =C2=A0 =C2=A0 =C2=A0 9221 =C2=A045% =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- python-nav-end-of-block
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 8609 =C2=A042% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 - python-nav-beginning-of-block
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 8557 =C2=A042% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0- python-nav-backward-block
=C2=A0 =C2=A0 =C2=A0 =C2=A0 8557 =C2= =A042% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 - pyt= hon-nav-forward-block
=C2=A0 =C2=A0 =C2=A0 =C2=A0 8005 =C2=A039% =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- python-synt= ax-context-type
=C2=A0 =C2=A0 =C2=A0 =C2=A0 7997 =C2=A039% =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 - syntax-ppss
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 7097 =C2=A035% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0parse-partial-sexp
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0753 =C2=A0 3% =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0+ #<byte-code-function = A23>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0376 =C2=A0 1% =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0+ python-nav-beginni= ng-of-statement
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0132 =C2=A0 0% =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0re-sea= rch-backward
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 24 =C2=A0 0% =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0looking-a= t
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 28 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0current-indentation
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A08 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0+ python-nav-beginning-of-statement=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A04 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0python-info-current-line-e= mpty-p
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A04 =C2=A0 0% =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0+ python-info-current-l= ine-comment-p
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0604 =C2=A0 2% =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 + python-nav-end-of-statement=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A04 =C2=A0 0% =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 + python-info-current-line-comment-p=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A04 =C2=A0 0% =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 current-indentation
=C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 24 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0+ python-nav-end-of-statement
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A08 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 + python-info-end-of-statement-p
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = 8178 =C2=A040% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- python-inf= o-statement-ends-block-p
=C2=A0 =C2=A0 =C2=A0 =C2=A0 8150 =C2=A040% =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 - python-nav-end-of-block
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 7754 =C2=A038% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0- python-nav-beginning-of-block
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 7738 =C2=A038% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 - python-nav-backward-block
=C2=A0 =C2=A0 =C2=A0 =C2=A0 7734 = =C2=A038% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- p= ython-nav-forward-block
=C2=A0 =C2=A0 =C2=A0 =C2=A0 7178 =C2=A035% =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 - python-syntax= -context-type
=C2=A0 =C2=A0 =C2=A0 =C2=A0 7174 =C2=A035% =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- syntax-ppss
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 6978 =C2=A034% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 parse-partial-sexp
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A08 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 make-closure
=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A08 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 #<byte-code-function B1E>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A04 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 syntax-table
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A04 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 syntax-ppss--update= -stats
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0412 =C2=A0 2% =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 + python-nav-beginning-of-sta= tement
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 92 =C2=A0 0% =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 re-search-backward
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 44 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 looking-at
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 12 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 current-indentation
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A04 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 looking-at
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0380 =C2=A0 1% = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0+ python-nav-end-of-= statement
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 16 =C2=A0 0% =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0+ python-util-forward-comment
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 28 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 + python-nav-end-of-statement
=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0151 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0+ python-nav-end-of-block
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 28 =C2= =A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0+ python-info-beginn= ing-of-block-p
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 24 =C2=A0 0% =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0+ python-info-end-of-statement-p=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 20 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0+ python-info-beginning-of-statement-p
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A08 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0+ python-syntax-context-type
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A08 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0+ python-info-statement-starts-block-p
=C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A04 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0+ syntax-ppss=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A08 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0= =C2=A0 + #<byte-code-function 7E0>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A04 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 + #<byte-code-funct= ion 740>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 80 =C2=A0 0% =C2=A0 =C2= =A0 =C2=A0 =C2=A0+ font-lock-fontify-syntactically-region
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 2279 =C2=A011% =C2=A0 Automatic GC
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 73 =C2=A0 0% + redisplay_internal (C function)
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 40 =C2=A0 0% + command-execute
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A08 =C2=A0 0% + ...
=C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A04 =C2=A0 0% + mouse--click-1-maybe-follows-link

other = people talking about python/profiling/syntax-ppss :

https://www.reddit.com/r/emacs/comments/z0oye9/emacs_freezes_when= _opening_a_python_file/
https://= www.reddit.com/r/emacs/comments/9h7onq/large_python_files_hanging_with_an_u= nmatched_quote/

Please tell me how I can help ?

Please te= ll me if there is a workaround without losing python syntax color ?

= Thanks

Rehan



In GNU Emacs 31.0.50 (build 1, x86_64-pc= -linux-gnu, GTK+ Version
=C2=A03.24.43, cairo version 1.18.2) of 2024-12= -08 built on cndl
Repository revision: b953bcb17047998c9e41cede7c5e5ffec= 22209b2
Repository branch: master
System Description: Debian GNU/Linu= x trixie/sid

Configured using:
=C2=A0'configure --prefix=3D/h= ome/jean/local/emacs --with-pgtk'

Configured features:
CAIRO = DBUS FREETYPE GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG LIBSELINUX
LIBXML2= MODULES NOTIFY INOTIFY PDUMPER PGTK PNG SECCOMP SOUND THREADS
TIFF TOOL= KIT_SCROLL_BARS WEBP XIM GTK3 ZLIB

Important settings:
=C2=A0 val= ue of $LANG: en_US.UTF-8
=C2=A0 value of $XMODIFIERS: @im=3Dibus
=C2= =A0 locale-coding-system: utf-8-unix

Major mode: Python

Minor= modes in effect:
=C2=A0 tooltip-mode: t
=C2=A0 global-eldoc-mode: t<= br>=C2=A0 eldoc-mode: t
=C2=A0 show-paren-mode: t
=C2=A0 electric-ind= ent-mode: t
=C2=A0 mouse-wheel-mode: t
=C2=A0 tool-bar-mode: t
=C2= =A0 menu-bar-mode: t
=C2=A0 file-name-shadow-mode: t
=C2=A0 global-fo= nt-lock-mode: t
=C2=A0 font-lock-mode: t
=C2=A0 blink-cursor-mode: t<= br>=C2=A0 minibuffer-regexp-mode: t
=C2=A0 line-number-mode: t
=C2=A0= transient-mark-mode: t
=C2=A0 auto-composition-mode: t
=C2=A0 auto-e= ncryption-mode: t
=C2=A0 auto-compression-mode: t

Load-path shado= ws:
None found.

Features:
(shadow sort mail-extr emacsbug mess= age mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec pass= word-cache epa derived epg rfc6068
epg-config gnus-util text-property-se= arch time-date mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbr= ev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail= -prsvr mail-utils cl-seq python
rx project byte-opt gv bytecomp byte-com= pile compat pcase treesit comint
subr-x ansi-osc ring cl-loaddefs cl-lib= ansi-color rmc iso-transl
tooltip cconv eldoc paren electric uniquify e= diff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/pgtk-win pgtk-= win term/common-win
touch-screen pgtk-dnd tool-bar dnd fontset image reg= exp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode pro= g-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer= select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-co= lors
frame minibuffer nadvice seq simple cl-generic indonesian philippin= e
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet la= o
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czecheuropean ethiopic indian cyrillic chinese composite emoji-zwj charscriptcharprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosurecl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
fi= les window text-properties overlay sha1 md5 base64 format env
code-pages= mule custom widget keymap hashtable-print-readable backquote
threads db= usbind inotify dynamic-setting system-font-setting
font-render-setting c= airo gtk pgtk multi-tty move-toolbar
make-network-process emacs)

= Memory information:
((conses 16 60995 13527) (symbols 48 7517 0) (string= s 32 19122 1493)
=C2=A0(string-bytes 1 515162) (vectors 16 13554)
=C2= =A0(vector-slots 8 145472 8433) (floats 8 26 2) (intervals 56 436 0)
=C2= =A0(buffers 984 12))
--000000000000f308ff0628c1e1b6-- From unknown Sun Jun 22 00:15:17 2025 X-Loop: help-debbugs@gnu.org Subject: bug#74738: 31.0.50; Freezes in Python-mode on some Python file when searching or scrolling Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 08 Dec 2024 17:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74738 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: rehan malak , Stefan Monnier , kobarity Cc: 74738@debbugs.gnu.org Received: via spool by 74738-submit@debbugs.gnu.org id=B74738.173367945620453 (code B ref 74738); Sun, 08 Dec 2024 17:38:02 +0000 Received: (at 74738) by debbugs.gnu.org; 8 Dec 2024 17:37:36 +0000 Received: from localhost ([127.0.0.1]:51590 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKLDr-0005Jo-0S for submit@debbugs.gnu.org; Sun, 08 Dec 2024 12:37:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42760) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKLDo-0005JU-AM for 74738@debbugs.gnu.org; Sun, 08 Dec 2024 12:37:33 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tKLDh-000864-VJ; Sun, 08 Dec 2024 12:37:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=kyjEHu+J51Xcpe1plVHMbY47ix8LCG+IvmDCKTVgIiw=; b=eSsiKJQHsfYT EmgW1QfNeQ6lm7STDpwFy6vKVvo4stvpvcH4HE63mlmLc69qOzHzT0MKiVDxpj6WrQ9XccmUMHU2A HP5rLrWkVOxVSi9NMgunljv2C9Oa4EikwQo0pY3nmVzOXZUphRoGf+UJs7ZhqwmILIetrTFga16IK WEaT49Idi3enp1FhvYn7Jq2RM89iTpaeBdKcfPwtLSS++kJrAuOfzgaHbZklcSwD2X6ug4HwRM+SZ hntW+rVspQ16/wEKvOV0kuy6UP9cx6Clp+Mf4itGAWhxXSQ50MBaOslgzdHfqC1D96N11cod67vYa Y/2MJHGPV2yHQr4TeUaFLQ==; Date: Sun, 08 Dec 2024 19:37:02 +0200 Message-Id: <868qsqf54x.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (message from rehan malak on Sun, 8 Dec 2024 14:05:36 +0100) References: X-Spam-Score: -1.6 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) > From: rehan malak > Date: Sun, 8 Dec 2024 14:05:36 +0100 > > I can reproduce systematically this freeze dealing with a 10000lines > Python file : > > wget https://raw.githubusercontent.com/hugsy/gef/refs/heads/main/gef.py > emacs -Q gef.py A much smaller reproducer is attached below. Just visiting it freezes Emacs. But if I change the line marked below: @classmethod def is_valid(cls, _: pathlib.Path) -> bool: raise NotImplementedError def __str__(self) -> str: >>>>> return f"{self.name}('{self.path.absolute()}', entry @ {self.entry_point:#x})" to say this instead: return self.name the problem goes away. So it is something in that complex expression that trips syntax-ppss. Stefan and kobarity, any suggestions or ideas? > PageDown several times or scrolling with the mouse > > Emacs freezes, Ctrl-g not working, CPU 100% > > It works also by searching : Ctrl-s show RET > then Ctrl-s several times > > With a minimal .emacs : > > (set debug-on-error t) > (set debug-on-quit t) > > and before scrolling > > M-x profiler-start RET > > then in an external terminal > > pkill -SIGUSR2 emacs > > I get the backtrace : > > Debugger entered--entering a function: > * #f(compiled-function () #)() > syntax-ppss() > python-syntax-context-type() > python-nav-forward-block(-1) > python-nav-backward-block() > python-nav-beginning-of-block() > python-nav-end-of-block() > python-info-statement-ends-block-p() > python-info-end-of-block-p() > python-nav--forward-sexp(1 nil nil) > python-nav-forward-sexp(1) > forward-sexp(1) > up-list(1) > python--font-lock-f-strings(30419) > font-lock-fontify-keywords-region(28914 30419 nil) > font-lock-default-fontify-region(28914 30414 nil) > font-lock-fontify-region(28914 30414) > #f(compiled-function (fun) #)(font-lock-fontify-region) > run-hook-wrapped(#f(compiled-function (fun) #) font-lock-fontify-region) > jit-lock--run-functions(28914 30414) > jit-lock-fontify-now(28914 30414) > jit-lock-function(28914) I see something different, in GDB: Lisp Backtrace: "parse-partial-sexp" (0x9f1a788) "syntax-ppss" (0x9f1a710) "python-info-line-ends-backslash-p" (0x9f1a6b8) "python-nav-end-of-statement" (0x9f1a670) "python-nav-end-of-block" (0x9f1a630) "python-info-statement-ends-block-p" (0x9f1a610) "python-info-end-of-block-p" (0x9f1a5c0) "python-nav--forward-sexp" (0x9f1a548) "python-nav-forward-sexp" (0x9f1a4f8) "forward-sexp" (0x9f1a4a8) "up-list" (0x9f1a438) "python--font-lock-f-strings" (0x9f1a3a0) "font-lock-fontify-keywords-region" (0x9f1a308) "font-lock-default-fontify-region" (0x9f1a2a0) "font-lock-fontify-region" (0x9f1a230) 0xb9117d0 PVEC_CLOSURE "run-hook-wrapped" (0x9f1a1c0) "jit-lock--run-functions" (0x9f1a0e8) "jit-lock-fontify-now" (0x9f1a058) "jit-lock-function" (0x5ffba98) "redisplay_internal (C function)" (0x0) Here's the file with which I can reproduce the problem? class FileFormat: name: str path: pathlib.Path entry_point: int checksec: dict[str, bool] sections: list[FileFormatSection] def __init__(self, path: str | pathlib.Path) -> None: raise NotImplementedError def __init_subclass__(cls: Type["FileFormat"], **kwargs): global __registered_file_formats__ super().__init_subclass__(**kwargs) required_attributes = ("name", "entry_point", "is_valid", "checksec",) for attr in required_attributes: if not hasattr(cls, attr): raise NotImplementedError(f"File format '{cls.__name__}' is invalid: missing attribute '{attr}'") __registered_file_formats__.add(cls) return @classmethod def is_valid(cls, _: pathlib.Path) -> bool: raise NotImplementedError def __str__(self) -> str: return f"{self.name}('{self.path.absolute()}', entry @ {self.entry_point:#x})" class Elf(FileFormat): """Basic ELF parsing. Ref: - http://www.skyfree.org/linux/references/ELF_Format.pdf - https://refspecs.linuxfoundation.org/elf/elfspec_ppc.pdf - https://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html """ class Class(enum.Enum): ELF_32_BITS = 0x01 ELF_64_BITS = 0x02 ELF_MAGIC = 0x7f454c46 class Abi(enum.Enum): X86_64 = 0x3e X86_32 = 0x03 ARM = 0x28 MIPS = 0x08 POWERPC = 0x14 POWERPC64 = 0x15 SPARC = 0x02 SPARC64 = 0x2b AARCH64 = 0xb7 RISCV = 0xf3 IA64 = 0x32 M68K = 0x04 class Type(enum.Enum): ET_RELOC = 1 ET_EXEC = 2 ET_DYN = 3 ET_CORE = 4 class OsAbi(enum.Enum): SYSTEMV = 0x00 HPUX = 0x01 NETBSD = 0x02 LINUX = 0x03 SOLARIS = 0x06 AIX = 0x07 IRIX = 0x08 FREEBSD = 0x09 OPENBSD = 0x0C e_magic: int = ELF_MAGIC e_class: "Elf.Class" = Class.ELF_32_BITS e_endianness: Endianness = Endianness.LITTLE_ENDIAN e_eiversion: int e_osabi: "Elf.OsAbi" e_abiversion: int e_pad: bytes e_type: "Elf.Type" = Type.ET_EXEC e_machine: Abi = Abi.X86_32 e_version: int e_entry: int e_phoff: int e_shoff: int e_flags: int e_ehsize: int e_phentsize: int e_phnum: int e_shentsize: int e_shnum: int e_shstrndx: int path: pathlib.Path phdrs : list["Phdr"] shdrs : list["Shdr"] name: str = "ELF" __checksec : dict[str, bool] def __init__(self, path: str | pathlib.Path) -> None: """Instantiate an ELF object. A valid ELF must be provided, or an exception will be thrown.""" if isinstance(path, str): self.path = pathlib.Path(path).expanduser() elif isinstance(path, pathlib.Path): self.path = path else: raise TypeError if not self.path.exists(): raise FileNotFoundError(f"'{self.path}' not found/readable, most gef features will not work") self.__checksec = {} with self.path.open("rb") as self.fd: # off 0x0 self.e_magic, e_class, e_endianness, self.e_eiversion = self.read_and_unpack(">IBBB") if self.e_magic != Elf.ELF_MAGIC: # The ELF is corrupted, GDB won't handle it, no point going further raise RuntimeError("Not a valid ELF file (magic)") self.e_class, self.e_endianness = Elf.Class(e_class), Endianness(e_endianness) if self.e_endianness != gef.arch.endianness: warn("Unexpected endianness for architecture") endian = self.e_endianness # off 0x7 e_osabi, self.e_abiversion = self.read_and_unpack(f"{endian}BB") self.e_osabi = Elf.OsAbi(e_osabi) # off 0x9 self.e_pad = self.read(7) # off 0x10 e_type, e_machine, self.e_version = self.read_and_unpack(f"{endian}HHI") self.e_type, self.e_machine = Elf.Type(e_type), Elf.Abi(e_machine) # off 0x18 if self.e_class == Elf.Class.ELF_64_BITS: self.e_entry, self.e_phoff, self.e_shoff = self.read_and_unpack(f"{endian}QQQ") else: self.e_entry, self.e_phoff, self.e_shoff = self.read_and_unpack(f"{endian}III") self.e_flags, self.e_ehsize, self.e_phentsize, self.e_phnum = self.read_and_unpack(f"{endian}IHHH") self.e_shentsize, self.e_shnum, self.e_shstrndx = self.read_and_unpack(f"{endian}HHH") self.phdrs = [] for i in range(self.e_phnum): self.phdrs.append(Phdr(self, self.e_phoff + self.e_phentsize * i)) self.shdrs = [] for i in range(self.e_shnum): self.shdrs.append(Shdr(self, self.e_shoff + self.e_shentsize * i)) return def read(self, size: int) -> bytes: return self.fd.read(size) def read_and_unpack(self, fmt: str) -> tuple[Any, ...]: size = struct.calcsize(fmt) data = self.fd.read(size) return struct.unpack(fmt, data) def seek(self, off: int) -> None: self.fd.seek(off, 0) def __str__(self) -> str: return f"ELF('{self.path.absolute()}', {self.e_class.name}, {self.e_machine.name})" def __repr__(self) -> str: return f"ELF('{self.path.absolute()}', {self.e_class.name}, {self.e_machine.name})" @property def entry_point(self) -> int: return self.e_entry @classmethod def is_valid(cls, path: pathlib.Path) -> bool: return u32(path.open("rb").read(4), e = Endianness.BIG_ENDIAN) == Elf.ELF_MAGIC @property def checksec(self) -> dict[str, bool]: """Check the security property of the ELF binary. The following properties are: - Canary - NX - PIE - Fortify - Partial/Full RelRO. Return a dict() with the different keys mentioned above, and the boolean associated whether the protection was found.""" if not self.__checksec: def __check_security_property(opt: str, filename: str, pattern: str) -> bool: cmd = [readelf,] cmd += opt.split() cmd += [filename,] lines = gef_execute_external(cmd, as_list=True) for line in lines: if re.search(pattern, line): return True return False abspath = str(self.path.absolute()) readelf = gef.session.constants["readelf"] self.__checksec["Canary"] = __check_security_property("-rs", abspath, r"__stack_chk_fail") is True has_gnu_stack = __check_security_property("-W -l", abspath, r"GNU_STACK") is True if has_gnu_stack: self.__checksec["NX"] = __check_security_property("-W -l", abspath, r"GNU_STACK.*RWE") is False else: self.__checksec["NX"] = False self.__checksec["PIE"] = __check_security_property("-h", abspath, r":.*EXEC") is False self.__checksec["Fortify"] = __check_security_property("-s", abspath, r"_chk@GLIBC") is True self.__checksec["Partial RelRO"] = __check_security_property("-l", abspath, r"GNU_RELRO") is True self.__checksec["Full RelRO"] = self.__checksec["Partial RelRO"] and __check_security_property("-d", abspath, r"BIND_NOW") is True return self.__checksec @classproperty @deprecated("use `Elf.Abi.X86_64`") def X86_64(cls) -> int: return Elf.Abi.X86_64.value # pylint: disable=no-self-argument @classproperty @deprecated("use `Elf.Abi.X86_32`") def X86_32(cls) -> int : return Elf.Abi.X86_32.value # pylint: disable=no-self-argument @classproperty @deprecated("use `Elf.Abi.ARM`") def ARM(cls) -> int : return Elf.Abi.ARM.value # pylint: disable=no-self-argument @classproperty @deprecated("use `Elf.Abi.MIPS`") def MIPS(cls) -> int : return Elf.Abi.MIPS.value # pylint: disable=no-self-argument @classproperty @deprecated("use `Elf.Abi.POWERPC`") def POWERPC(cls) -> int : return Elf.Abi.POWERPC.value # pylint: disable=no-self-argument @classproperty @deprecated("use `Elf.Abi.POWERPC64`") def POWERPC64(cls) -> int : return Elf.Abi.POWERPC64.value # pylint: disable=no-self-argument @classproperty @deprecated("use `Elf.Abi.SPARC`") def SPARC(cls) -> int : return Elf.Abi.SPARC.value # pylint: disable=no-self-argument @classproperty @deprecated("use `Elf.Abi.SPARC64`") def SPARC64(cls) -> int : return Elf.Abi.SPARC64.value # pylint: disable=no-self-argument @classproperty @deprecated("use `Elf.Abi.AARCH64`") def AARCH64(cls) -> int : return Elf.Abi.AARCH64.value # pylint: disable=no-self-argument @classproperty @deprecated("use `Elf.Abi.RISCV`") def RISCV(cls) -> int : return Elf.Abi.RISCV.value # pylint: disable=no-self-argument From unknown Sun Jun 22 00:15:17 2025 X-Loop: help-debbugs@gnu.org Subject: bug#74738: 31.0.50; Freezes in Python-mode on some Python file when searching or scrolling Resent-From: kobarity Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 09 Dec 2024 15:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74738 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: rehan malak , Eli Zaretskii Cc: 74738@debbugs.gnu.org, Stefan Monnier Received: via spool by 74738-submit@debbugs.gnu.org id=B74738.17337567556422 (code B ref 74738); Mon, 09 Dec 2024 15:06:02 +0000 Received: (at 74738) by debbugs.gnu.org; 9 Dec 2024 15:05:55 +0000 Received: from localhost ([127.0.0.1]:55149 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKfKc-0001fV-Ui for submit@debbugs.gnu.org; Mon, 09 Dec 2024 10:05:55 -0500 Received: from mail-pl1-f174.google.com ([209.85.214.174]:48437) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKfKa-0001f0-KF for 74738@debbugs.gnu.org; Mon, 09 Dec 2024 10:05:53 -0500 Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-21644e6140cso12250385ad.1 for <74738@debbugs.gnu.org>; Mon, 09 Dec 2024 07:05:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733756686; x=1734361486; darn=debbugs.gnu.org; h=mime-version:user-agent:references:in-reply-to:subject:cc:to:from :message-id:date:from:to:cc:subject:date:message-id:reply-to; bh=ylLCLpIeIl7K/gJSRy2pBPLhBxm3MZWs4tnh8Q6GXLg=; b=cI41bIxK78xik2n+kj/SQ3byzJz9yFyLXnaNedjVZiCNUywzHTa5NcvHYWBatne92n loyNRA55mPTcvMVaNGcK8iGpgkpUB1/F9zP9cUOivfo5mVgJED2N/LcWvC8BIlQ2CZHZ DV6VidBhBdy1vsiEOv9BEaQ3U+3SUDg19dTHRGhVVXbK1K/a2AA5BQtAFaAGznLXab7m Q7Xcx3RLTvLIHM6Cqqk5ZrjEbgxar8q+VKsw1IphmLqan7vXsaDE8nFSArPSVnVHeBUl rbtVYp8L07P6WS67ZtvXKZzSJ9qSZgJrb315wELYaDSXt3rh4n2HkdRbmOj2DF/i5rTx utWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733756686; x=1734361486; h=mime-version:user-agent:references:in-reply-to:subject:cc:to:from :message-id:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ylLCLpIeIl7K/gJSRy2pBPLhBxm3MZWs4tnh8Q6GXLg=; b=IRytVQedtCv3EO6UIaaJ0WUHZoFKOwp5i6yF9NI0dXlhnh5zsD7N6Rj1CBF0tn74hv YOtTzq2YiWLvfIiFdm2AUTjXb9o2+4bcHw0tpUJoAPMYISTyIHkX1cFsQJclosovwGSI PTY/osv7uN+jtP90YZK0K+b53VesokEBmVoEgqvT8fE/bZtIJHG3Tll1Xc/s3ZuKf2ed pheL73+v/RkGAYKIh27zdmRY3RQI1HltY+jqPKkyzS2y1j72zdWhBn30HV8KSSrKcbfx Hy8yQN0yN7oI4/tK742t2fV4zI/rU18czGmlhfpkRq78EZoKDFAI6lS5YB1q4n7MQs/U SZlA== X-Forwarded-Encrypted: i=1; AJvYcCX87KggpdTCTd9uHH+EV3IuVwjngcC9/2Up3LFNilwlW29AhAn8nBtMjAFchwYXp44+2udZhA==@debbugs.gnu.org X-Gm-Message-State: AOJu0YzOwFnoTh6x1J82CCa0REN5vYv3ZCCqUoBdHchIm2RF97tm6a7t hKCKciqQuaRUarMrX5ujPkAyFgfhG567B/zgr1PGmm0OiQvjG2jU X-Gm-Gg: ASbGnct0JUOiEwKc8AlYSv+vXorvCeIUOYzA07go6RVDY/Bjv8vBETO92eZoIvZy2Ly 5FDtXVXsjCPzBY9B8ueZZx10lqN1xDzP0iZKCJOY+X775Z2LUyWXGUSou/TPoZmrYYWEi+i2xJX 4Z3FFFb7qUrVfuIV912EuiLcWNxcMXztyKdJFiSvhPzsB2SETPUWxp8nJiLP2KjbmSKcqXXkhTs ma8ZuPsQCN8tkUVY2Hn+Z6+2q8oIJQ/oUxbsS3lzZR7aSpVFatWLhcKi4dy1FV6erzl1TFNVjh9 iKYD X-Google-Smtp-Source: AGHT+IF+sDDWBmCeWx00vW+3QDMLLn/8RFcKy9tPb+O6b1E1ER7JDOE4HorP3FZMjeOH9nrjFPAhUA== X-Received: by 2002:a17:902:ea07:b0:212:996:353a with SMTP id d9443c01a7336-21669fc936amr13071945ad.12.1733756686355; Mon, 09 Dec 2024 07:04:46 -0800 (PST) Received: from localhost (58x12x133x161.ap58.ftth.ucom.ne.jp. [58.12.133.161]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21615dba950sm57051845ad.11.2024.12.09.07.04.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2024 07:04:45 -0800 (PST) Date: Tue, 10 Dec 2024 00:04:28 +0900 Message-ID: From: kobarity In-Reply-To: <868qsqf54x.fsf@gnu.org> References: <868qsqf54x.fsf@gnu.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?Q?Goj=C5=8D?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/31.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-Spam-Score: 0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.3 (/) rehan malak wrote: > Please tell me if there is a workaround without losing python syntax color ? If you can configure Emacs to use tree-sitter, python-ts-mode would not be affected by this problem. Eli Zaretskii wrote: > > > From: rehan malak > > Date: Sun, 8 Dec 2024 14:05:36 +0100 > > > > I can reproduce systematically this freeze dealing with a 10000lines > > Python file : > > > > wget https://raw.githubusercontent.com/hugsy/gef/refs/heads/main/gef.py > > emacs -Q gef.py It seems to be reproducible after the following commit: commit 3b3274a85c2f5df21d76d82e0d7740005aa84fdf Author: Stefan Monnier Date: Fri Oct 16 14:03:59 2020 -0400 * lisp/progmodes/python.el: Teach f-strings to `font-lock` (python--f-string-p, python--font-lock-f-strings): New functions. (python-font-lock-keywords-maximum-decoration): Use them. > A much smaller reproducer is attached below. Just visiting it freezes > Emacs. But if I change the line marked below: > > @classmethod > def is_valid(cls, _: pathlib.Path) -> bool: > raise NotImplementedError > > def __str__(self) -> str: > >>>>> return f"{self.name}('{self.path.absolute()}', entry @ {self.entry_point:#x})" > > to say this instead: > > return self.name > > the problem goes away. So it is something in that complex expression > that trips syntax-ppss. > > Stefan and kobarity, any suggestions or ideas? I could not reproduce the freeze, but it took several seconds to visit the reproducer. It appears to be possible to work around this by simply removing the format specifier ":#x". return f"{self.name}('{self.path.absolute()}', entry @ {self.entry_point})" So there may be a problem with font-lock when there is an f-string format specifier, but I have not found the root cause yet. From unknown Sun Jun 22 00:15:17 2025 X-Loop: help-debbugs@gnu.org Subject: bug#74738: 31.0.50; Freezes in Python-mode on some Python file when searching or scrolling Resent-From: rehan malak Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 09 Dec 2024 15:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74738 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: kobarity , Stefan Monnier , 74738@debbugs.gnu.org Received: via spool by 74738-submit@debbugs.gnu.org id=B74738.173375787310108 (code B ref 74738); Mon, 09 Dec 2024 15:25:02 +0000 Received: (at 74738) by debbugs.gnu.org; 9 Dec 2024 15:24:33 +0000 Received: from localhost ([127.0.0.1]:55187 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKfcd-0002cu-H3 for submit@debbugs.gnu.org; Mon, 09 Dec 2024 10:24:33 -0500 Received: from mail-vs1-f46.google.com ([209.85.217.46]:50252) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKfCo-00017j-B5 for 74738@debbugs.gnu.org; Mon, 09 Dec 2024 09:57:56 -0500 Received: by mail-vs1-f46.google.com with SMTP id ada2fe7eead31-4afe1009960so620213137.0 for <74738@debbugs.gnu.org>; Mon, 09 Dec 2024 06:57:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733756209; x=1734361009; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=BEGISY+VV9WnBfaD4/OfHpmYZ2N2zlZLeMVeFIfqZ6E=; b=GcrbLlT/am0N6HG41tCtrGzOWViITRy7+n5Ihe7zPoN8FQ35qrAXGuh1FI5wCG4N4i 9LDNRtttmjzQVOKJhxcGCWlTrqdT9cEthrzoImoVpaSQizrOvHJFcc6qdmqRSudub0wS iKngl2oz0cyeLtDsjVSTm9mQH6MHO/ADBwoGMm/gVA3Vfb5Rg0gLnZRkyNZR+YoQ050f hD3+RdadD93IMMhd/pJhaMYWNty0CJ+UO6O648yXc7yW2Ua4ZXBCtpuJa56dgXYb/MsY 1newzxLT37hfP1CwqQ/uN0H8gaIxj2xw/LJHtIef+84rtdQ7x7CJ+hZYpnVUOIgu229C i6jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733756209; x=1734361009; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BEGISY+VV9WnBfaD4/OfHpmYZ2N2zlZLeMVeFIfqZ6E=; b=OCJym1TPq8VzRgvZfJDyEpZST0zfGkSqLXsIm9BU/rnLIaNA0Tf/iLeciElsrVwgYx jerJYtyKV1sMpjtU1Zr5o+hKnSlh2kIHjZZJmr/nu2a1pjHf4lP1FBg4HJslLHzd4bfW C8Hy67Zpjb7u4xYc4UDHUFcJ9XNaFsYQCPA78IsCej7eTiWWySdRllO3S9/e8YXNUAZ6 /Q0GW90oxcQsGpE6SJupR8si3ff9otDd2rJ5jdTzw9ARNfrFkDcD1AeEmIrRueudHAWC TWij2NyGLnaWcKRF3B70HKcPgx+/uVlZnYREbyNErs5La/PAHs2yEfHKrWZcB064HcKb Ap/A== X-Forwarded-Encrypted: i=1; AJvYcCVAd/Uu7La7A5xPxUkimreKbYSF/S+U/VzSZFVp/8Ksi61+FbkHXwaN1ya8VhbwZVanYjhjdA==@debbugs.gnu.org X-Gm-Message-State: AOJu0Yx/ddU9LGeMVtBKqAuJ79C7CYcWzr2hgQag1mxxAR5T4Q9z8QzE ypQnDYz5abmtZWrfw+qBZ4eVjcTC7FRamMIjhkXW+/PtVJcv7NQ2o2SuY7x6X0nXrwlharOsHxr ogyMKRMmzTSJ0gKzPBwWNBryRcWI= X-Gm-Gg: ASbGncsKh/nZrhad6/0YOxPsDHAmA1akgSx0m8VEqWoI5OoFCnTbyWN4jdoYReZ0eUL 2GikbSvoAgiod20aKMqy8PQJiRIixBAVU X-Google-Smtp-Source: AGHT+IGZ9BSOEeR1hawEJx14XhLUnEflc5hh7q973quEQKYHZ34JCsLkaZ4/boMf4P19C0B2/3IMvSXUcO5MQM2ghAo= X-Received: by 2002:a05:6102:b14:b0:4af:3f89:44d8 with SMTP id ada2fe7eead31-4b116104d25mr943980137.8.1733756209496; Mon, 09 Dec 2024 06:56:49 -0800 (PST) MIME-Version: 1.0 References: <868qsqf54x.fsf@gnu.org> In-Reply-To: <868qsqf54x.fsf@gnu.org> From: rehan malak Date: Mon, 9 Dec 2024 15:58:22 +0100 Message-ID: Content-Type: multipart/alternative; boundary="000000000000fe8bf80628d79205" X-Spam-Score: 0.7 (/) X-Mailman-Approved-At: Mon, 09 Dec 2024 10:24:29 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.3 (/) --000000000000fe8bf80628d79205 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, Deleting all the "#" in the f-string of the gef.py file removes the problem on my side. sed -i -e 's/#0{align/0{align/g' gef.py sed -i -e 's/#0{width/0{width/g' gef.py sed -i -e 's/#07x}/07x}/g' gef.py sed -i -e 's/#06x}/06x}/g' gef.py sed -i -e 's/#04x}/04x}/g' gef.py sed -i -e 's/#4x}/4x}/g' gef.py sed -i -e 's/#8x}/8x}/g' gef.py sed -i -e 's/#10x}/10x}/g' gef.py sed -i -e 's/#x}/x}/g' gef.py Your smaller example Eli also contains a f-string with the "#". This python f-string format specifier is described here: https://docs.python.org/3/library/string.html#format-specification-mini-lan= guage Is this format specifier supported from the beginning ? For example : value =3D 0xab print(f"{value:x} is a value") =3D> color syntax : *is a value* has the color defined by font-lock-string-face while value =3D 0xab print(f"{value:#x} is a value") =3D> color are messed up... *is* has color defined by font-lock-keyword-fac= e and *a value* has color defined by default face Best, Rehan On Sun, Dec 8, 2024 at 6:37=E2=80=AFPM Eli Zaretskii wrote: > > From: rehan malak > > Date: Sun, 8 Dec 2024 14:05:36 +0100 > > > > I can reproduce systematically this freeze dealing with a 10000lines > > Python file : > > > > wget https://raw.githubusercontent.com/hugsy/gef/refs/heads/main/gef.py > > emacs -Q gef.py > > A much smaller reproducer is attached below. Just visiting it freezes > Emacs. But if I change the line marked below: > > @classmethod > def is_valid(cls, _: pathlib.Path) -> bool: > raise NotImplementedError > > def __str__(self) -> str: > >>>>> return f"{self.name}('{self.path.absolute()}', entry @ > {self.entry_point:#x})" > > to say this instead: > > return self.name > > the problem goes away. So it is something in that complex expression > that trips syntax-ppss. > > Stefan and kobarity, any suggestions or ideas? > > > PageDown several times or scrolling with the mouse > > > > Emacs freezes, Ctrl-g not working, CPU 100% > > > > It works also by searching : Ctrl-s show RET > > then Ctrl-s several times > > > > With a minimal .emacs : > > > > (set debug-on-error t) > > (set debug-on-quit t) > > > > and before scrolling > > > > M-x profiler-start RET > > > > then in an external terminal > > > > pkill -SIGUSR2 emacs > > > > I get the backtrace : > > > > Debugger entered--entering a function: > > * #f(compiled-function () #)() > > syntax-ppss() > > python-syntax-context-type() > > python-nav-forward-block(-1) > > python-nav-backward-block() > > python-nav-beginning-of-block() > > python-nav-end-of-block() > > python-info-statement-ends-block-p() > > python-info-end-of-block-p() > > python-nav--forward-sexp(1 nil nil) > > python-nav-forward-sexp(1) > > forward-sexp(1) > > up-list(1) > > python--font-lock-f-strings(30419) > > font-lock-fontify-keywords-region(28914 30419 nil) > > font-lock-default-fontify-region(28914 30414 nil) > > font-lock-fontify-region(28914 30414) > > #f(compiled-function (fun) # -0x8a96d65e1315e71>)(font-lock-fontify-region) > > run-hook-wrapped(#f(compiled-function (fun) # -0x8a96d65e1315e71>) font-lock-fontify-region) > > jit-lock--run-functions(28914 30414) > > jit-lock-fontify-now(28914 30414) > > jit-lock-function(28914) > > I see something different, in GDB: > > Lisp Backtrace: > "parse-partial-sexp" (0x9f1a788) > "syntax-ppss" (0x9f1a710) > "python-info-line-ends-backslash-p" (0x9f1a6b8) > "python-nav-end-of-statement" (0x9f1a670) > "python-nav-end-of-block" (0x9f1a630) > "python-info-statement-ends-block-p" (0x9f1a610) > "python-info-end-of-block-p" (0x9f1a5c0) > "python-nav--forward-sexp" (0x9f1a548) > "python-nav-forward-sexp" (0x9f1a4f8) > "forward-sexp" (0x9f1a4a8) > "up-list" (0x9f1a438) > "python--font-lock-f-strings" (0x9f1a3a0) > "font-lock-fontify-keywords-region" (0x9f1a308) > "font-lock-default-fontify-region" (0x9f1a2a0) > "font-lock-fontify-region" (0x9f1a230) > 0xb9117d0 PVEC_CLOSURE > "run-hook-wrapped" (0x9f1a1c0) > "jit-lock--run-functions" (0x9f1a0e8) > "jit-lock-fontify-now" (0x9f1a058) > "jit-lock-function" (0x5ffba98) > "redisplay_internal (C function)" (0x0) > > Here's the file with which I can reproduce the problem? > > > class FileFormat: > name: str > path: pathlib.Path > entry_point: int > checksec: dict[str, bool] > sections: list[FileFormatSection] > > def __init__(self, path: str | pathlib.Path) -> None: > raise NotImplementedError > > def __init_subclass__(cls: Type["FileFormat"], **kwargs): > global __registered_file_formats__ > super().__init_subclass__(**kwargs) > required_attributes =3D ("name", "entry_point", "is_valid", > "checksec",) > for attr in required_attributes: > if not hasattr(cls, attr): > raise NotImplementedError(f"File format '{cls.__name__}' > is invalid: missing attribute '{attr}'") > __registered_file_formats__.add(cls) > return > > @classmethod > def is_valid(cls, _: pathlib.Path) -> bool: > raise NotImplementedError > > def __str__(self) -> str: > return f"{self.name}('{self.path.absolute()}', entry @ > {self.entry_point:#x})" > > > class Elf(FileFormat): > """Basic ELF parsing. > Ref: > - http://www.skyfree.org/linux/references/ELF_Format.pdf > - https://refspecs.linuxfoundation.org/elf/elfspec_ppc.pdf > - https://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html > """ > class Class(enum.Enum): > ELF_32_BITS =3D 0x01 > ELF_64_BITS =3D 0x02 > > ELF_MAGIC =3D 0x7f454c46 > > class Abi(enum.Enum): > X86_64 =3D 0x3e > X86_32 =3D 0x03 > ARM =3D 0x28 > MIPS =3D 0x08 > POWERPC =3D 0x14 > POWERPC64 =3D 0x15 > SPARC =3D 0x02 > SPARC64 =3D 0x2b > AARCH64 =3D 0xb7 > RISCV =3D 0xf3 > IA64 =3D 0x32 > M68K =3D 0x04 > > class Type(enum.Enum): > ET_RELOC =3D 1 > ET_EXEC =3D 2 > ET_DYN =3D 3 > ET_CORE =3D 4 > > class OsAbi(enum.Enum): > SYSTEMV =3D 0x00 > HPUX =3D 0x01 > NETBSD =3D 0x02 > LINUX =3D 0x03 > SOLARIS =3D 0x06 > AIX =3D 0x07 > IRIX =3D 0x08 > FREEBSD =3D 0x09 > OPENBSD =3D 0x0C > > e_magic: int =3D ELF_MAGIC > e_class: "Elf.Class" =3D Class.ELF_32_BITS > e_endianness: Endianness =3D Endianness.LITTLE_ENDIAN > e_eiversion: int > e_osabi: "Elf.OsAbi" > e_abiversion: int > e_pad: bytes > e_type: "Elf.Type" =3D Type.ET_EXEC > e_machine: Abi =3D Abi.X86_32 > e_version: int > e_entry: int > e_phoff: int > e_shoff: int > e_flags: int > e_ehsize: int > e_phentsize: int > e_phnum: int > e_shentsize: int > e_shnum: int > e_shstrndx: int > > path: pathlib.Path > phdrs : list["Phdr"] > shdrs : list["Shdr"] > name: str =3D "ELF" > > __checksec : dict[str, bool] > > def __init__(self, path: str | pathlib.Path) -> None: > """Instantiate an ELF object. A valid ELF must be provided, or an > exception will be thrown.""" > > if isinstance(path, str): > self.path =3D pathlib.Path(path).expanduser() > elif isinstance(path, pathlib.Path): > self.path =3D path > else: > raise TypeError > > if not self.path.exists(): > raise FileNotFoundError(f"'{self.path}' not found/readable, > most gef features will not work") > > self.__checksec =3D {} > > with self.path.open("rb") as self.fd: > # off 0x0 > self.e_magic, e_class, e_endianness, self.e_eiversion =3D > self.read_and_unpack(">IBBB") > if self.e_magic !=3D Elf.ELF_MAGIC: > # The ELF is corrupted, GDB won't handle it, no point > going further > raise RuntimeError("Not a valid ELF file (magic)") > > self.e_class, self.e_endianness =3D Elf.Class(e_class), > Endianness(e_endianness) > > if self.e_endianness !=3D gef.arch.endianness: > warn("Unexpected endianness for architecture") > > endian =3D self.e_endianness > > # off 0x7 > e_osabi, self.e_abiversion =3D > self.read_and_unpack(f"{endian}BB") > self.e_osabi =3D Elf.OsAbi(e_osabi) > > # off 0x9 > self.e_pad =3D self.read(7) > > # off 0x10 > e_type, e_machine, self.e_version =3D > self.read_and_unpack(f"{endian}HHI") > self.e_type, self.e_machine =3D Elf.Type(e_type), > Elf.Abi(e_machine) > > # off 0x18 > if self.e_class =3D=3D Elf.Class.ELF_64_BITS: > self.e_entry, self.e_phoff, self.e_shoff =3D > self.read_and_unpack(f"{endian}QQQ") > else: > self.e_entry, self.e_phoff, self.e_shoff =3D > self.read_and_unpack(f"{endian}III") > > self.e_flags, self.e_ehsize, self.e_phentsize, self.e_phnum = =3D > self.read_and_unpack(f"{endian}IHHH") > self.e_shentsize, self.e_shnum, self.e_shstrndx =3D > self.read_and_unpack(f"{endian}HHH") > > self.phdrs =3D [] > for i in range(self.e_phnum): > self.phdrs.append(Phdr(self, self.e_phoff + > self.e_phentsize * i)) > > self.shdrs =3D [] > for i in range(self.e_shnum): > self.shdrs.append(Shdr(self, self.e_shoff + > self.e_shentsize * i)) > return > > def read(self, size: int) -> bytes: > return self.fd.read(size) > > def read_and_unpack(self, fmt: str) -> tuple[Any, ...]: > size =3D struct.calcsize(fmt) > data =3D self.fd.read(size) > return struct.unpack(fmt, data) > > def seek(self, off: int) -> None: > self.fd.seek(off, 0) > > def __str__(self) -> str: > return f"ELF('{self.path.absolute()}', {self.e_class.name}, { > self.e_machine.name})" > > def __repr__(self) -> str: > return f"ELF('{self.path.absolute()}', {self.e_class.name}, { > self.e_machine.name})" > > @property > def entry_point(self) -> int: > return self.e_entry > > @classmethod > def is_valid(cls, path: pathlib.Path) -> bool: > return u32(path.open("rb").read(4), e =3D Endianness.BIG_ENDIAN) = =3D=3D > Elf.ELF_MAGIC > > @property > def checksec(self) -> dict[str, bool]: > """Check the security property of the ELF binary. The following > properties are: > - Canary > - NX > - PIE > - Fortify > - Partial/Full RelRO. > Return a dict() with the different keys mentioned above, and the > boolean > associated whether the protection was found.""" > if not self.__checksec: > def __check_security_property(opt: str, filename: str, > pattern: str) -> bool: > cmd =3D [readelf,] > cmd +=3D opt.split() > cmd +=3D [filename,] > lines =3D gef_execute_external(cmd, as_list=3DTrue) > for line in lines: > if re.search(pattern, line): > return True > return False > > abspath =3D str(self.path.absolute()) > readelf =3D gef.session.constants["readelf"] > self.__checksec["Canary"] =3D __check_security_property("-rs"= , > abspath, r"__stack_chk_fail") is True > has_gnu_stack =3D __check_security_property("-W -l", abspath, > r"GNU_STACK") is True > if has_gnu_stack: > self.__checksec["NX"] =3D __check_security_property("-W -= l", > abspath, r"GNU_STACK.*RWE") is False > else: > self.__checksec["NX"] =3D False > self.__checksec["PIE"] =3D __check_security_property("-h", > abspath, r":.*EXEC") is False > self.__checksec["Fortify"] =3D __check_security_property("-s"= , > abspath, r"_chk@GLIBC") is True > self.__checksec["Partial RelRO"] =3D > __check_security_property("-l", abspath, r"GNU_RELRO") is True > self.__checksec["Full RelRO"] =3D self.__checksec["Partial > RelRO"] and __check_security_property("-d", abspath, r"BIND_NOW") is True > return self.__checksec > > @classproperty > @deprecated("use `Elf.Abi.X86_64`") > def X86_64(cls) -> int: return Elf.Abi.X86_64.value # pylint: > disable=3Dno-self-argument > > @classproperty > @deprecated("use `Elf.Abi.X86_32`") > def X86_32(cls) -> int : return Elf.Abi.X86_32.value # pylint: > disable=3Dno-self-argument > > @classproperty > @deprecated("use `Elf.Abi.ARM`") > def ARM(cls) -> int : return Elf.Abi.ARM.value # pylint: > disable=3Dno-self-argument > > @classproperty > @deprecated("use `Elf.Abi.MIPS`") > def MIPS(cls) -> int : return Elf.Abi.MIPS.value # pylint: > disable=3Dno-self-argument > > @classproperty > @deprecated("use `Elf.Abi.POWERPC`") > def POWERPC(cls) -> int : return Elf.Abi.POWERPC.value # pylint: > disable=3Dno-self-argument > > @classproperty > @deprecated("use `Elf.Abi.POWERPC64`") > def POWERPC64(cls) -> int : return Elf.Abi.POWERPC64.value # pylint: > disable=3Dno-self-argument > > @classproperty > @deprecated("use `Elf.Abi.SPARC`") > def SPARC(cls) -> int : return Elf.Abi.SPARC.value # pylint: > disable=3Dno-self-argument > > @classproperty > @deprecated("use `Elf.Abi.SPARC64`") > def SPARC64(cls) -> int : return Elf.Abi.SPARC64.value # pylint: > disable=3Dno-self-argument > > @classproperty > @deprecated("use `Elf.Abi.AARCH64`") > def AARCH64(cls) -> int : return Elf.Abi.AARCH64.value # pylint: > disable=3Dno-self-argument > > @classproperty > @deprecated("use `Elf.Abi.RISCV`") > def RISCV(cls) -> int : return Elf.Abi.RISCV.value # pylint: > disable=3Dno-self-argument > > --000000000000fe8bf80628d79205 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

Dele= ting all the "#" in the f-string of the gef.py file removes the p= roblem on my side.
=C2=A0sed -i -e 's/#0{align/0{align/g&= #39; gef.py
=C2=A0sed -i -e 's/#0{width/0{width/g' gef.py
=C2= =A0sed -i -e 's/#07x}/07x}/g' gef.py
=C2=A0sed -i -e 's/#06x= }/06x}/g' gef.py
=C2=A0sed -i -e 's/#04x}/04x}/g' gef.py
= =C2=A0sed -i -e 's/#4x}/4x}/g' gef.py
=C2=A0sed -i -e 's/#8x= }/8x}/g' gef.py
=C2=A0sed -i -e 's/#10x}/10x}/g' gef.py
= =C2=A0sed -i -e 's/#x}/x}/g' gef.py

Your smaller example Eli= also contains a f-string with the "#".

<= div>This python f-string format specifier is described here: https://docs.python.org/3/library/string.html#format-specification-mini= -language

Is this format specifier supported from the be= ginning ?

For example :

value =3D 0xab
print(f"= {value:x} is a value")

=3D> color syntax : is = a value=C2=A0=C2=A0=C2=A0 has the color defined by font-lock-string-fac= e

while

value =3D 0xab
print(f"{value:#x} = is a value")

=3D> color are messed up... is has color defined by font-lock-keyword-face and a value has color = defined by default face

Best,

=
Rehan=C2=A0

On Sun, Dec 8, 2024 at 6:3= 7=E2=80=AFPM Eli Zaretskii <eliz@gnu.org= > wrote:
= > From: rehan malak <rehan.malak@gmail.com>
> Date: Sun, 8 Dec 2024 14:05:36 +0100
>
> I can reproduce systematically this freeze dealing with a 10000lines > Python file :
>
> wget https://raw.githubuserco= ntent.com/hugsy/gef/refs/heads/main/gef.py
> emacs -Q gef.py

A much smaller reproducer is attached below.=C2=A0 Just visiting it freezes=
Emacs.=C2=A0 But if I change the line marked below:

=C2=A0 =C2=A0 @classmethod
=C2=A0 =C2=A0 def is_valid(cls, _: pathlib.Path) -> bool:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 raise NotImplementedError

=C2=A0 =C2=A0 def __str__(self) -> str:
=C2=A0 >>>>> return f"{self.name}('{self.path.absolute()= }', entry @ {self.entry_point:#x})"

to say this instead:

=C2=A0 =C2=A0 =C2=A0 =C2=A0 return self.name

the problem goes away.=C2=A0 So it is something in that complex expression<= br> that trips syntax-ppss.

Stefan and kobarity, any suggestions or ideas?

> PageDown several times or scrolling with the mouse
>
> Emacs freezes, Ctrl-g not working, CPU 100%
>
> It works also by searching : Ctrl-s show RET
> then Ctrl-s several times
>
> With a minimal .emacs :
>
> (set debug-on-error t)
> (set debug-on-quit t)
>
> and before scrolling
>
> M-x profiler-start RET
>
> then in an external terminal
>
> pkill -SIGUSR2 emacs
>
> I get the backtrace :
>
> Debugger entered--entering a function:
> * #f(compiled-function () #<bytecode -0x179dcd1db31182ae>)()
>=C2=A0 =C2=A0syntax-ppss()
>=C2=A0 =C2=A0python-syntax-context-type()
>=C2=A0 =C2=A0python-nav-forward-block(-1)
>=C2=A0 =C2=A0python-nav-backward-block()
>=C2=A0 =C2=A0python-nav-beginning-of-block()
>=C2=A0 =C2=A0python-nav-end-of-block()
>=C2=A0 =C2=A0python-info-statement-ends-block-p()
>=C2=A0 =C2=A0python-info-end-of-block-p()
>=C2=A0 =C2=A0python-nav--forward-sexp(1 nil nil)
>=C2=A0 =C2=A0python-nav-forward-sexp(1)
>=C2=A0 =C2=A0forward-sexp(1)
>=C2=A0 =C2=A0up-list(1)
>=C2=A0 =C2=A0python--font-lock-f-strings(30419)
>=C2=A0 =C2=A0font-lock-fontify-keywords-region(28914 30419 nil)
>=C2=A0 =C2=A0font-lock-default-fontify-region(28914 30414 nil)
>=C2=A0 =C2=A0font-lock-fontify-region(28914 30414)
>=C2=A0 =C2=A0#f(compiled-function (fun) #<bytecode -0x8a96d65e1315e7= 1>)(font-lock-fontify-region)
>=C2=A0 =C2=A0run-hook-wrapped(#f(compiled-function (fun) #<bytecode = -0x8a96d65e1315e71>) font-lock-fontify-region)
>=C2=A0 =C2=A0jit-lock--run-functions(28914 30414)
>=C2=A0 =C2=A0jit-lock-fontify-now(28914 30414)
>=C2=A0 =C2=A0jit-lock-function(28914)

I see something different, in GDB:

=C2=A0 Lisp Backtrace:
=C2=A0 "parse-partial-sexp" (0x9f1a788)
=C2=A0 "syntax-ppss" (0x9f1a710)
=C2=A0 "python-info-line-ends-backslash-p" (0x9f1a6b8)
=C2=A0 "python-nav-end-of-statement" (0x9f1a670)
=C2=A0 "python-nav-end-of-block" (0x9f1a630)
=C2=A0 "python-info-statement-ends-block-p" (0x9f1a610)
=C2=A0 "python-info-end-of-block-p" (0x9f1a5c0)
=C2=A0 "python-nav--forward-sexp" (0x9f1a548)
=C2=A0 "python-nav-forward-sexp" (0x9f1a4f8)
=C2=A0 "forward-sexp" (0x9f1a4a8)
=C2=A0 "up-list" (0x9f1a438)
=C2=A0 "python--font-lock-f-strings" (0x9f1a3a0)
=C2=A0 "font-lock-fontify-keywords-region" (0x9f1a308)
=C2=A0 "font-lock-default-fontify-region" (0x9f1a2a0)
=C2=A0 "font-lock-fontify-region" (0x9f1a230)
=C2=A0 0xb9117d0 PVEC_CLOSURE
=C2=A0 "run-hook-wrapped" (0x9f1a1c0)
=C2=A0 "jit-lock--run-functions" (0x9f1a0e8)
=C2=A0 "jit-lock-fontify-now" (0x9f1a058)
=C2=A0 "jit-lock-function" (0x5ffba98)
=C2=A0 "redisplay_internal (C function)" (0x0)

Here's the file with which I can reproduce the problem?


class FileFormat:
=C2=A0 =C2=A0 name: str
=C2=A0 =C2=A0 path: pathlib.Path
=C2=A0 =C2=A0 entry_point: int
=C2=A0 =C2=A0 checksec: dict[str, bool]
=C2=A0 =C2=A0 sections: list[FileFormatSection]

=C2=A0 =C2=A0 def __init__(self, path: str | pathlib.Path) -> None:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 raise NotImplementedError

=C2=A0 =C2=A0 def __init_subclass__(cls: Type["FileFormat"], **kw= args):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 global __registered_file_formats__
=C2=A0 =C2=A0 =C2=A0 =C2=A0 super().__init_subclass__(**kwargs)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 required_attributes =3D ("name", &quo= t;entry_point", "is_valid", "checksec",)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 for attr in required_attributes:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if not hasattr(cls, attr):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 raise NotImplemente= dError(f"File format '{cls.__name__}' is invalid: missing attr= ibute '{attr}'")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 __registered_file_formats__.add(cls)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return

=C2=A0 =C2=A0 @classmethod
=C2=A0 =C2=A0 def is_valid(cls, _: pathlib.Path) -> bool:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 raise NotImplementedError

=C2=A0 =C2=A0 def __str__(self) -> str:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return f"{self.name}('{self.path.absolute()= }', entry @ {self.entry_point:#x})"


class Elf(FileFormat):
=C2=A0 =C2=A0 """Basic ELF parsing.
=C2=A0 =C2=A0 Ref:
=C2=A0 =C2=A0 - http://www.skyfree.org/linux/r= eferences/ELF_Format.pdf
=C2=A0 =C2=A0 - https://refspecs.linuxfounda= tion.org/elf/elfspec_ppc.pdf
=C2=A0 =C2=A0 - https://refspecs.lin= uxfoundation.org/ELF/ppc64/PPC-elf64abi.html
=C2=A0 =C2=A0 """
=C2=A0 =C2=A0 class Class(enum.Enum):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ELF_32_BITS=C2=A0 =C2=A0 =C2=A0 =C2=A0=3D 0x01<= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 ELF_64_BITS=C2=A0 =C2=A0 =C2=A0 =C2=A0=3D 0x02<= br>
=C2=A0 =C2=A0 ELF_MAGIC=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D 0x7f454c46

=C2=A0 =C2=A0 class Abi(enum.Enum):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 X86_64=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =3D 0x3e
=C2=A0 =C2=A0 =C2=A0 =C2=A0 X86_32=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =3D 0x03
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ARM=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0=3D 0x28
=C2=A0 =C2=A0 =C2=A0 =C2=A0 MIPS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =3D 0x08
=C2=A0 =C2=A0 =C2=A0 =C2=A0 POWERPC=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0=3D 0x14
=C2=A0 =C2=A0 =C2=A0 =C2=A0 POWERPC64=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D = 0x15
=C2=A0 =C2=A0 =C2=A0 =C2=A0 SPARC=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0=3D 0x02
=C2=A0 =C2=A0 =C2=A0 =C2=A0 SPARC64=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0=3D 0x2b
=C2=A0 =C2=A0 =C2=A0 =C2=A0 AARCH64=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0=3D 0xb7
=C2=A0 =C2=A0 =C2=A0 =C2=A0 RISCV=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0=3D 0xf3
=C2=A0 =C2=A0 =C2=A0 =C2=A0 IA64=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =3D 0x32
=C2=A0 =C2=A0 =C2=A0 =C2=A0 M68K=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =3D 0x04

=C2=A0 =C2=A0 class Type(enum.Enum):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ET_RELOC=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D = 1
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ET_EXEC=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0=3D 2
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ET_DYN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =3D 3
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ET_CORE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0=3D 4

=C2=A0 =C2=A0 class OsAbi(enum.Enum):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 SYSTEMV=C2=A0 =C2=A0 =C2=A0=3D 0x00
=C2=A0 =C2=A0 =C2=A0 =C2=A0 HPUX=C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D 0x01
=C2=A0 =C2=A0 =C2=A0 =C2=A0 NETBSD=C2=A0 =C2=A0 =C2=A0 =3D 0x02
=C2=A0 =C2=A0 =C2=A0 =C2=A0 LINUX=C2=A0 =C2=A0 =C2=A0 =C2=A0=3D 0x03
=C2=A0 =C2=A0 =C2=A0 =C2=A0 SOLARIS=C2=A0 =C2=A0 =C2=A0=3D 0x06
=C2=A0 =C2=A0 =C2=A0 =C2=A0 AIX=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D 0x07 =C2=A0 =C2=A0 =C2=A0 =C2=A0 IRIX=C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D 0x08
=C2=A0 =C2=A0 =C2=A0 =C2=A0 FREEBSD=C2=A0 =C2=A0 =C2=A0=3D 0x09
=C2=A0 =C2=A0 =C2=A0 =C2=A0 OPENBSD=C2=A0 =C2=A0 =C2=A0=3D 0x0C

=C2=A0 =C2=A0 e_magic: int=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =3D ELF_MAGIC
=C2=A0 =C2=A0 e_class: "Elf.Class"=C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D= Class.ELF_32_BITS
=C2=A0 =C2=A0 e_endianness: Endianness=C2=A0 =C2=A0 =3D Endianness.LITTLE_E= NDIAN
=C2=A0 =C2=A0 e_eiversion: int
=C2=A0 =C2=A0 e_osabi: "Elf.OsAbi"
=C2=A0 =C2=A0 e_abiversion: int
=C2=A0 =C2=A0 e_pad: bytes
=C2=A0 =C2=A0 e_type: "Elf.Type"=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =3D Type.ET_EXEC
=C2=A0 =C2=A0 e_machine: Abi=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =3D Abi.X86_32
=C2=A0 =C2=A0 e_version: int
=C2=A0 =C2=A0 e_entry: int
=C2=A0 =C2=A0 e_phoff: int
=C2=A0 =C2=A0 e_shoff: int
=C2=A0 =C2=A0 e_flags: int
=C2=A0 =C2=A0 e_ehsize: int
=C2=A0 =C2=A0 e_phentsize: int
=C2=A0 =C2=A0 e_phnum: int
=C2=A0 =C2=A0 e_shentsize: int
=C2=A0 =C2=A0 e_shnum: int
=C2=A0 =C2=A0 e_shstrndx: int

=C2=A0 =C2=A0 path: pathlib.Path
=C2=A0 =C2=A0 phdrs : list["Phdr"]
=C2=A0 =C2=A0 shdrs : list["Shdr"]
=C2=A0 =C2=A0 name: str =3D "ELF"

=C2=A0 =C2=A0 __checksec : dict[str, bool]

=C2=A0 =C2=A0 def __init__(self, path: str | pathlib.Path) -> None:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 """Instantiate an ELF object. A = valid ELF must be provided, or an exception will be thrown.""&quo= t;

=C2=A0 =C2=A0 =C2=A0 =C2=A0 if isinstance(path, str):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.path =3D pathlib.Path(path).= expanduser()
=C2=A0 =C2=A0 =C2=A0 =C2=A0 elif isinstance(path, pathlib.Path):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.path =3D path
=C2=A0 =C2=A0 =C2=A0 =C2=A0 else:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 raise TypeError

=C2=A0 =C2=A0 =C2=A0 =C2=A0 if not self.path.exists():
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 raise FileNotFoundError(f"&#= 39;{self.path}' not found/readable, most gef features will not work&quo= t;)

=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.__checksec =3D {}

=C2=A0 =C2=A0 =C2=A0 =C2=A0 with self.path.open("rb") as self.fd:=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # off 0x0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.e_magic, e_class, e_endianne= ss, self.e_eiversion =3D self.read_and_unpack(">IBBB")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if self.e_magic !=3D Elf.ELF_MAGI= C:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # The ELF is corrup= ted, GDB won't handle it, no point going further
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 raise RuntimeError(= "Not a valid ELF file (magic)")

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.e_class, self.e_endianness = =3D Elf.Class(e_class), Endianness(e_endianness)

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if self.e_endianness !=3D gef.arc= h.endianness:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 warn("Unexpect= ed endianness for architecture")

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 endian =3D self.e_endianness

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # off 0x7
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 e_osabi, self.e_abiversion =3D se= lf.read_and_unpack(f"{endian}BB")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.e_osabi =3D Elf.OsAbi(e_osab= i)

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # off 0x9
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.e_pad =3D self.read(7)

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # off 0x10
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 e_type, e_machine, self.e_version= =3D self.read_and_unpack(f"{endian}HHI")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.e_type, self.e_machine =3D E= lf.Type(e_type), Elf.Abi(e_machine)

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # off 0x18
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if self.e_class =3D=3D Elf.Class.= ELF_64_BITS:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.e_entry, self.= e_phoff, self.e_shoff =3D self.read_and_unpack(f"{endian}QQQ") =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 else:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.e_entry, self.= e_phoff, self.e_shoff =3D self.read_and_unpack(f"{endian}III")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.e_flags, self.e_ehsize, self= .e_phentsize, self.e_phnum =3D self.read_and_unpack(f"{endian}IHHH&quo= t;)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.e_shentsize, self.e_shnum, s= elf.e_shstrndx =3D self.read_and_unpack(f"{endian}HHH")

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.phdrs =3D []
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for i in range(self.e_phnum):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.phdrs.append(P= hdr(self, self.e_phoff + self.e_phentsize * i))

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.shdrs =3D []
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for i in range(self.e_shnum):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.shdrs.append(S= hdr(self, self.e_shoff + self.e_shentsize * i))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return

=C2=A0 =C2=A0 def read(self, size: int) -> bytes:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return self.fd.read(size)

=C2=A0 =C2=A0 def read_and_unpack(self, fmt: str) -> tuple[Any, ...]: =C2=A0 =C2=A0 =C2=A0 =C2=A0 size =3D struct.calcsize(fmt)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 data =3D self.fd.read(size)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return struct.unpack(fmt, data)

=C2=A0 =C2=A0 def seek(self, off: int) -> None:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 self.fd.seek(off, 0)

=C2=A0 =C2=A0 def __str__(self) -> str:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return f"ELF('{self.path.absolute()}&#= 39;, {self.e_class.name}, {self.e_machine.name})"

=C2=A0 =C2=A0 def __repr__(self) -> str:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return f"ELF('{self.path.absolute()}&#= 39;, {self.e_class.name}, {self.e_machine.name})"

=C2=A0 =C2=A0 @property
=C2=A0 =C2=A0 def entry_point(self) -> int:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return self.e_entry

=C2=A0 =C2=A0 @classmethod
=C2=A0 =C2=A0 def is_valid(cls, path: pathlib.Path) -> bool:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return u32(path.open("rb").read(4), e= =3D Endianness.BIG_ENDIAN) =3D=3D Elf.ELF_MAGIC

=C2=A0 =C2=A0 @property
=C2=A0 =C2=A0 def checksec(self) -> dict[str, bool]:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 """Check the security property o= f the ELF binary. The following properties are:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 - Canary
=C2=A0 =C2=A0 =C2=A0 =C2=A0 - NX
=C2=A0 =C2=A0 =C2=A0 =C2=A0 - PIE
=C2=A0 =C2=A0 =C2=A0 =C2=A0 - Fortify
=C2=A0 =C2=A0 =C2=A0 =C2=A0 - Partial/Full RelRO.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Return a dict() with the different keys mention= ed above, and the boolean
=C2=A0 =C2=A0 =C2=A0 =C2=A0 associated whether the protection was found.&qu= ot;""
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if not self.__checksec:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 def __check_security_property(opt= : str, filename: str, pattern: str) -> bool:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cmd=C2=A0 =C2=A0=3D= [readelf,]
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cmd=C2=A0 +=3D opt.= split()
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cmd=C2=A0 +=3D [fil= ename,]
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 lines =3D gef_execu= te_external(cmd, as_list=3DTrue)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for line in lines:<= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if re= .search(pattern, line):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 return True
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return False

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 abspath =3D str(self.path.absolut= e())
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 readelf =3D gef.session.constants= ["readelf"]
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.__checksec["Canary"= ;] =3D __check_security_property("-rs", abspath, r"__stack_c= hk_fail") is True
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 has_gnu_stack =3D __check_securit= y_property("-W -l", abspath, r"GNU_STACK") is True
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if has_gnu_stack:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.__checksec[&qu= ot;NX"] =3D __check_security_property("-W -l", abspath, r&qu= ot;GNU_STACK.*RWE") is False
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 else:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.__checksec[&qu= ot;NX"] =3D False
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.__checksec["PIE"] = =3D __check_security_property("-h", abspath, r":.*EXEC"= ) is False
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.__checksec["Fortify&quo= t;] =3D __check_security_property("-s", abspath, r"_chk@GLIB= C") is True
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.__checksec["Partial Rel= RO"] =3D __check_security_property("-l", abspath, r"GNU= _RELRO") is True
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 self.__checksec["Full RelRO&= quot;] =3D self.__checksec["Partial RelRO"] and __check_security_= property("-d", abspath, r"BIND_NOW") is True
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return self.__checksec

=C2=A0 =C2=A0 @classproperty
=C2=A0 =C2=A0 @deprecated("use `Elf.Abi.X86_64`")
=C2=A0 =C2=A0 def X86_64(cls) -> int: return Elf.Abi.X86_64.value # pyli= nt: disable=3Dno-self-argument

=C2=A0 =C2=A0 @classproperty
=C2=A0 =C2=A0 @deprecated("use `Elf.Abi.X86_32`")
=C2=A0 =C2=A0 def X86_32(cls) -> int : return Elf.Abi.X86_32.value # pyl= int: disable=3Dno-self-argument

=C2=A0 =C2=A0 @classproperty
=C2=A0 =C2=A0 @deprecated("use `Elf.Abi.ARM`")
=C2=A0 =C2=A0 def ARM(cls) -> int : return Elf.Abi.ARM.value # pylint: d= isable=3Dno-self-argument

=C2=A0 =C2=A0 @classproperty
=C2=A0 =C2=A0 @deprecated("use `Elf.Abi.MIPS`")
=C2=A0 =C2=A0 def MIPS(cls) -> int : return Elf.Abi.MIPS.value # pylint:= disable=3Dno-self-argument

=C2=A0 =C2=A0 @classproperty
=C2=A0 =C2=A0 @deprecated("use `Elf.Abi.POWERPC`")
=C2=A0 =C2=A0 def POWERPC(cls) -> int : return Elf.Abi.POWERPC.value # p= ylint: disable=3Dno-self-argument

=C2=A0 =C2=A0 @classproperty
=C2=A0 =C2=A0 @deprecated("use `Elf.Abi.POWERPC64`")
=C2=A0 =C2=A0 def POWERPC64(cls) -> int : return Elf.Abi.POWERPC64.value= # pylint: disable=3Dno-self-argument

=C2=A0 =C2=A0 @classproperty
=C2=A0 =C2=A0 @deprecated("use `Elf.Abi.SPARC`")
=C2=A0 =C2=A0 def SPARC(cls) -> int : return Elf.Abi.SPARC.value # pylin= t: disable=3Dno-self-argument

=C2=A0 =C2=A0 @classproperty
=C2=A0 =C2=A0 @deprecated("use `Elf.Abi.SPARC64`")
=C2=A0 =C2=A0 def SPARC64(cls) -> int : return Elf.Abi.SPARC64.value # p= ylint: disable=3Dno-self-argument

=C2=A0 =C2=A0 @classproperty
=C2=A0 =C2=A0 @deprecated("use `Elf.Abi.AARCH64`")
=C2=A0 =C2=A0 def AARCH64(cls) -> int : return Elf.Abi.AARCH64.value=C2= =A0 # pylint: disable=3Dno-self-argument

=C2=A0 =C2=A0 @classproperty
=C2=A0 =C2=A0 @deprecated("use `Elf.Abi.RISCV`")
=C2=A0 =C2=A0 def RISCV(cls) -> int : return Elf.Abi.RISCV.value # pylin= t: disable=3Dno-self-argument

--000000000000fe8bf80628d79205-- From unknown Sun Jun 22 00:15:17 2025 X-Loop: help-debbugs@gnu.org Subject: bug#74738: 31.0.50; Freezes in Python-mode on some Python file when searching or scrolling Resent-From: kobarity Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 11 Dec 2024 14:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74738 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: rehan malak , Eli Zaretskii Cc: 74738@debbugs.gnu.org, Stefan Monnier Received: via spool by 74738-submit@debbugs.gnu.org id=B74738.173392714611547 (code B ref 74738); Wed, 11 Dec 2024 14:26:02 +0000 Received: (at 74738) by debbugs.gnu.org; 11 Dec 2024 14:25:46 +0000 Received: from localhost ([127.0.0.1]:33656 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLNeq-000308-RW for submit@debbugs.gnu.org; Wed, 11 Dec 2024 09:25:45 -0500 Received: from mail-pf1-f176.google.com ([209.85.210.176]:44523) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLNel-0002zu-VJ for 74738@debbugs.gnu.org; Wed, 11 Dec 2024 09:25:42 -0500 Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-725f4025e25so2719075b3a.1 for <74738@debbugs.gnu.org>; Wed, 11 Dec 2024 06:25:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733927078; x=1734531878; darn=debbugs.gnu.org; h=mime-version:user-agent:references:in-reply-to:subject:cc:to:from :message-id:date:from:to:cc:subject:date:message-id:reply-to; bh=gKdRSiRN01C4K9uOdzmMOwqFJxgFSo/Qj0fqo82ofsM=; b=BgW+OwcFolADCm3qyJrylTBuzFUz0Hj37ptKo1zMg2JhDEDNqbTK2EOGOfz9kVu3Ee yjntGDbuXP5SMPV6AURURzejYnA3XFSa87RfSmwon9N81w+AzeabCAwMpWRSzko0z+Z0 81AG+GW/WJcz6vu7w3ZQKDjrjV7nTPg1ngJrWGPaGB/91U88znyYruojJHk1bUMWyJNe R55HyamuQLwePm7PmOXyqIykvXG57OmcSRvdPpWiONiBQL0E454vz+lAm/qUoqpfqjUr Ah3MHotJ8aanRFU40sCorbGnfE/RjoayYd7alP7PCFTaYWecll78LARJyolw4wyrM/Qt b9eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733927078; x=1734531878; h=mime-version:user-agent:references:in-reply-to:subject:cc:to:from :message-id:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=gKdRSiRN01C4K9uOdzmMOwqFJxgFSo/Qj0fqo82ofsM=; b=b6b/hSdR2zoGgW64V5M/Sfps7UUPu+MgrPNWhiax/axjicKTAfV7XG2pYyiWPkgi5+ FQGSbRVPNsUJBNQiRPLojqYdeSckGDB+f5NiENyLkzwrGxgekdHbhFKHBxND5rn/Ksko EHvAO1rqrDBM/9Pyz8BGtqUZYReoifzumPMlKYMpwXmo88Z2DOX7PLu3JI1GbbIsEV/U sEB+XciYCPgtk62Be0blEfmfgz6DU0jwPmYWHoEQZyNJ2EHZPZcTYuyScRm1yGquXwvk Pd8NfYkx7u79W/ba3pfPKxnWoktcWnObAZ+9IhKz+Yk4aE8daWKbECfvaGJahGxd4ZyL eQLQ== X-Forwarded-Encrypted: i=1; AJvYcCUnfRpYnbFBzmPlh/9CaryGAuojHWp9UAtNsGz3MEh1XW0grovn1qzGukWN7QYWb/KnTDOw9g==@debbugs.gnu.org X-Gm-Message-State: AOJu0Yyj2N7LqbZyt9LOI+yAMWnHGkjedPDUyru/AJbTColXjFnP80PY yLvflkQ+WApedMyvoqdJ016rq0QN9msG3e/PQkgJIoQ4b2GtOPEg X-Gm-Gg: ASbGncvh3+hS4GYqK2E3moR+qqBSPv347MKP5mGBj4RsGeRCdWzDARAbdnAeRup+Oq+ NMON4SByyes26aIOPNKeHcQs1eVpOnHlRkCU3m+EbafBkTd8xUsaLCeFq0BJPEyxZLzF2mvfLjc cxUk39TylwT8dKo/cxJ02pCvHeLluqlLVCeFlUSnmouQMXfYOlX9JJqHTa95JiQlEHM/EkogiZb UBN/2vCZrwMe04q152oPEg+om6Nns4UWtnxy64wxWLr4ifahECk6pyiv7EL/3IynE4s6Xs8lx4f Er1wgUDL X-Google-Smtp-Source: AGHT+IF/NehyN1K0+w6k5UZc7P/vhrY/HaJ3i+oaaGBM6e9rrmpTD0HBOhCVnLdaOG3z54l0ReXbRQ== X-Received: by 2002:a05:6a20:4307:b0:1e0:bb0d:b1f4 with SMTP id adf61e73a8af0-1e1c12b54e4mr5099159637.11.1733927077907; Wed, 11 Dec 2024 06:24:37 -0800 (PST) Received: from localhost (58x12x133x161.ap58.ftth.ucom.ne.jp. [58.12.133.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7263803a805sm4741743b3a.14.2024.12.11.06.24.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 06:24:37 -0800 (PST) Date: Wed, 11 Dec 2024 23:24:34 +0900 Message-ID: From: kobarity In-Reply-To: References: <868qsqf54x.fsf@gnu.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?Q?Goj=C5=8D?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/31.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: multipart/mixed; boundary="Multipart_Wed_Dec_11_23:24:34_2024-1" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --Multipart_Wed_Dec_11_23:24:34_2024-1 Content-Type: text/plain; charset=US-ASCII rehan malak wrote: > Deleting all the "#" in the f-string of the gef.py file removes the problem on my side. > sed -i -e 's/#0{align/0{align/g' gef.py > sed -i -e 's/#0{width/0{width/g' gef.py > sed -i -e 's/#07x}/07x}/g' gef.py > sed -i -e 's/#06x}/06x}/g' gef.py > sed -i -e 's/#04x}/04x}/g' gef.py > sed -i -e 's/#4x}/4x}/g' gef.py > sed -i -e 's/#8x}/8x}/g' gef.py > sed -i -e 's/#10x}/10x}/g' gef.py > sed -i -e 's/#x}/x}/g' gef.py > > Your smaller example Eli also contains a f-string with the "#". > > This python f-string format specifier is described here: > https://docs.python.org/3/library/string.html#format-specification-mini-language > > Is this format specifier supported from the beginning ? > > For example : > > value = 0xab > print(f"{value:x} is a value") > > => color syntax : is a value has the color defined by font-lock-string-face > > while > > value = 0xab > print(f"{value:#x} is a value") > > => color are messed up... is has color defined by font-lock-keyword-face and a value has color defined by default face The mechanism of the hang is still unclear, but I found the cause of the font-lock malfunction: when using `up-list' to find the corresponding closing brace for an opening brace in an f-string, if the format specifier contains "#", the rest of the string is considered a comment and the search fails. Therefore, it can be worked around by temporarily binding `parse-sexp-ignore-comments' to nil, as in the attached patch. Hangs on gef.py can also be avoided with this patch, but it assumes that the braces are properly closed. If you remove the closing braces of expressions containing "#", it will eventually hang. --Multipart_Wed_Dec_11_23:24:34_2024-1 Content-Type: text/plain; type=patch; name="0001-Fix-font-lock-of-Python-f-strings.patch"; charset=US-ASCII Content-Disposition: attachment; filename="0001-Fix-font-lock-of-Python-f-strings.patch" Content-Transfer-Encoding: 7bit >From 697f942d70e40bcd9bd32596313a9a371fffe35c Mon Sep 17 00:00:00 2001 From: kobarity Date: Wed, 11 Dec 2024 23:21:04 +0900 Subject: [PATCH] Fix font-lock of Python f-strings * lisp/progmodes/python.el (python--font-lock-f-strings): Bind 'parse-sexp-ignore-comments' to nil so that we can look for closing braces even if a hash is used in the format specifier. * test/lisp/progmodes/python-tests.el (python-font-lock-f-string-1): New test. (Bug#74738) --- lisp/progmodes/python.el | 4 +++- test/lisp/progmodes/python-tests.el | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index cfa3cc59568..827f437013f 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -631,7 +631,9 @@ python--font-lock-f-strings (forward-char 1) ;Just skip over {{ (let ((beg (match-beginning 0)) (end (condition-case nil - (progn (up-list 1) (min send (point))) + (let ((parse-sexp-ignore-comments)) + (up-list 1) + (min send (point))) (scan-error send)))) (goto-char end) (put-text-property beg end 'face nil)))) diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index 4cc4040d0ff..ac17c5b1263 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -709,6 +709,14 @@ python-font-lock-string-literal-concatenation (17 . font-lock-operator-face) (18) (19 . font-lock-string-face)))) +(ert-deftest python-font-lock-f-string-1 () + "Test for bug#74738." + (python-tests-assert-faces + "print(f\"{value:#x} is a value\")" + '((1 . font-lock-builtin-face) (6) + (8 . font-lock-string-face) (9) + (19 . font-lock-string-face) (31)))) + ;;; Indentation -- 2.43.0 --Multipart_Wed_Dec_11_23:24:34_2024-1-- From unknown Sun Jun 22 00:15:17 2025 X-Loop: help-debbugs@gnu.org Subject: bug#74738: 31.0.50; Freezes in Python-mode on some Python file when searching or scrolling Resent-From: rehan malak Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 12 Dec 2024 03:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74738 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: kobarity Cc: Eli Zaretskii , Stefan Monnier , 74738@debbugs.gnu.org Received: via spool by 74738-submit@debbugs.gnu.org id=B74738.173397534818882 (code B ref 74738); Thu, 12 Dec 2024 03:50:02 +0000 Received: (at 74738) by debbugs.gnu.org; 12 Dec 2024 03:49:08 +0000 Received: from localhost ([127.0.0.1]:37112 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLaCJ-0004uU-Np for submit@debbugs.gnu.org; Wed, 11 Dec 2024 22:49:08 -0500 Received: from mail-vk1-f169.google.com ([209.85.221.169]:45492) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLaCF-0004ti-Md for 74738@debbugs.gnu.org; Wed, 11 Dec 2024 22:49:06 -0500 Received: by mail-vk1-f169.google.com with SMTP id 71dfb90a1353d-5187f6f7bcaso38935e0c.3 for <74738@debbugs.gnu.org>; Wed, 11 Dec 2024 19:49:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733975278; x=1734580078; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=bOEuV6pqYzw/3gmR/p0XF6xEBRsLanv3ovGb6WADoK0=; b=FMynbjhQe9/kFZPLDoO0nGuOKgEfuVujklGMKBxCnyAyICJH+DXYvGa/huNQhVcPo5 F0lF6oEJyI0cVkQtHtQrtlgqWe8ehCzZt5d7Y5AHK8HL86MwHvXUXHpG6b4WeBkSAHOp RpSZU7XevtCojix2CwAjV1hlXtborh/mhj/BhEdAbBrd4atSg0bDpp5Tdqv30jg/+yL5 vDJG+nH8mPD23Ki+CE7339gAEIFo6uWxH/UJO4/Kw8O0aXM4OmUAtuLll3Mergc7YfIa Jtir+B4MuOXJWaD+OEJqHRmJ1FMRsRudB0YJ4qNvPnZVzuf6xFJdBBKNPHPBHvzY9va5 Xr0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733975278; x=1734580078; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bOEuV6pqYzw/3gmR/p0XF6xEBRsLanv3ovGb6WADoK0=; b=YEOybIU+MoEW1Lld4o8yVTkZe6mSgEY26ozRdaKfWJEbobJXHAnaR+3sUZq+GTOUVY x+5RTGvSyQVTjw0WnfPaJ4hEAOvcU2wvBbC5ZeQCjqNqyQOPGKqAn5RtwafdjB5lDPyu O1FBxbNokk2Yzw/dOyBWpDsS8/tn3UvQ4n4Q8P8mLjWEj59yChk8nF8UJI4yRVyC9C0M zAUn/TdtNEZXq1xHOsRv+wK1idJrTBaEv6CUZKvxU+s8lHE3mR9o90ECijN39PDFHvtF MVP7IHsUwwptOFKctdLQdwHivgYaY+7SsOmxkh7swMT9qClOFkvybVDnSJmFlvWRlG3R EOpw== X-Forwarded-Encrypted: i=1; AJvYcCWRjsbFZfka45M9xXJBXTcrdUn9GTjjg0JInJ/ZY0EBnOzqiKrRS52aZzJwsBT5nZnxTGL54A==@debbugs.gnu.org X-Gm-Message-State: AOJu0YxAXbZwgwjBJUyyJ2DzDOW1DPB4BoAnD7fwSBmB6ObQk9yQEWdG Z+zYK9ydvxktXgCC9WeiupU6pvHvBV0YfVZUxzLzZqEKF1VJjiimfStD9jY8njyKqJ1xB/yYXts cbWbhrph2q9jPKpx0kdyPEIHa2YY= X-Gm-Gg: ASbGncv13EFZZ9LlsIVzOf1L8pZQ7BqPyiUeJgff+OXH+C+qR+sS5bp1v8+S2S5HTV4 cwnklBC0mTkgXCtpl+sMTxEgh/Zzc6UVXwZw1lQ== X-Google-Smtp-Source: AGHT+IHVOBAgm8zwVkMoM5Ut0YGzoW/OpB7Ttt+pN1WM7ZTFC/wnnEWdpa0OGl9gD7arNlJEtm6vDd9QpF0qGhB8Lwc= X-Received: by 2002:a05:6122:4882:b0:518:a14e:7334 with SMTP id 71dfb90a1353d-518b5dfe3dfmr2053848e0c.12.1733975277983; Wed, 11 Dec 2024 19:47:57 -0800 (PST) MIME-Version: 1.0 References: <868qsqf54x.fsf@gnu.org> In-Reply-To: From: rehan malak Date: Thu, 12 Dec 2024 04:49:34 +0100 Message-ID: Content-Type: multipart/alternative; boundary="0000000000007e612b06290a9430" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --0000000000007e612b06290a9430 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable thanks kobarity, with your patch, I confirm that : - I can open gef.py and scroll - I get the correct font-lock-string-face in the f-string after a "#" in the format On Wed, Dec 11, 2024 at 3:24=E2=80=AFPM kobarity wrote= : > rehan malak wrote: > > Deleting all the "#" in the f-string of the gef.py file removes the > problem on my side. > > sed -i -e 's/#0{align/0{align/g' gef.py > > sed -i -e 's/#0{width/0{width/g' gef.py > > sed -i -e 's/#07x}/07x}/g' gef.py > > sed -i -e 's/#06x}/06x}/g' gef.py > > sed -i -e 's/#04x}/04x}/g' gef.py > > sed -i -e 's/#4x}/4x}/g' gef.py > > sed -i -e 's/#8x}/8x}/g' gef.py > > sed -i -e 's/#10x}/10x}/g' gef.py > > sed -i -e 's/#x}/x}/g' gef.py > > > > Your smaller example Eli also contains a f-string with the "#". > > > > This python f-string format specifier is described here: > > > https://docs.python.org/3/library/string.html#format-specification-mini-l= anguage > > > > Is this format specifier supported from the beginning ? > > > > For example : > > > > value =3D 0xab > > print(f"{value:x} is a value") > > > > =3D> color syntax : is a value has the color defined by > font-lock-string-face > > > > while > > > > value =3D 0xab > > print(f"{value:#x} is a value") > > > > =3D> color are messed up... is has color defined by font-lock-keyword-f= ace > and a value has color defined by default face > > The mechanism of the hang is still unclear, but I found the cause of > the font-lock malfunction: when using `up-list' to find the > corresponding closing brace for an opening brace in an f-string, if > the format specifier contains "#", the rest of the string is > considered a comment and the search fails. Therefore, it can be > worked around by temporarily binding `parse-sexp-ignore-comments' to > nil, as in the attached patch. > > Hangs on gef.py can also be avoided with this patch, but it assumes > that the braces are properly closed. If you remove the closing braces > of expressions containing "#", it will eventually hang. > --0000000000007e612b06290a9430 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
thanks kobarity, with your patch, I confirm that :
- I can open gef.py and scroll
- I get the correct font-lock-str= ing-face in the f-string after a "#" in the format
On Wed, Dec 11, 2024 at 3:24=E2=80=AFPM kobarity <kobarity@gmail.com> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l= eft:1px solid rgb(204,204,204);padding-left:1ex">rehan malak wrote:
> Deleting all the "#" in the f-string of the gef.py file remo= ves the problem on my side.
>=C2=A0 sed -i -e 's/#0{align/0{align/g' gef.py
>=C2=A0 sed -i -e 's/#0{width/0{width/g' gef.py
>=C2=A0 sed -i -e 's/#07x}/07x}/g' gef.py
>=C2=A0 sed -i -e 's/#06x}/06x}/g' gef.py
>=C2=A0 sed -i -e 's/#04x}/04x}/g' gef.py
>=C2=A0 sed -i -e 's/#4x}/4x}/g' gef.py
>=C2=A0 sed -i -e 's/#8x}/8x}/g' gef.py
>=C2=A0 sed -i -e 's/#10x}/10x}/g' gef.py
>=C2=A0 sed -i -e 's/#x}/x}/g' gef.py
>
> Your smaller example Eli also contains a f-string with the "#&quo= t;.
>
> This python f-string format specifier is described here:
> https://docs.py= thon.org/3/library/string.html#format-specification-mini-language
>
> Is this format specifier supported from the beginning ?
>
> For example :
>
> value =3D 0xab
> print(f"{value:x} is a value")
>
> =3D> color syntax : is a value=C2=A0 =C2=A0 has the color defined b= y font-lock-string-face
>
> while
>
> value =3D 0xab
> print(f"{value:#x} is a value")
>
> =3D> color are messed up... is has color defined by font-lock-keywo= rd-face and a value has color defined by default face

The mechanism of the hang is still unclear, but I found the cause of
the font-lock malfunction: when using `up-list' to find the
corresponding closing brace for an opening brace in an f-string, if
the format specifier contains "#", the rest of the string is
considered a comment and the search fails.=C2=A0 Therefore, it can be
worked around by temporarily binding `parse-sexp-ignore-comments' to nil, as in the attached patch.

Hangs on gef.py can also be avoided with this patch, but it assumes
that the braces are properly closed.=C2=A0 If you remove the closing braces=
of expressions containing "#", it will eventually hang.
--0000000000007e612b06290a9430-- From unknown Sun Jun 22 00:15:17 2025 X-Loop: help-debbugs@gnu.org Subject: bug#74738: 31.0.50; Freezes in Python-mode on some Python file when searching or scrolling Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 13 Dec 2024 23:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74738 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: kobarity Cc: rehan malak , Eli Zaretskii , 74738@debbugs.gnu.org Received: via spool by 74738-submit@debbugs.gnu.org id=B74738.173413293912913 (code B ref 74738); Fri, 13 Dec 2024 23:36:01 +0000 Received: (at 74738) by debbugs.gnu.org; 13 Dec 2024 23:35:39 +0000 Received: from localhost ([127.0.0.1]:44709 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tMFC6-0003MD-E1 for submit@debbugs.gnu.org; Fri, 13 Dec 2024 18:35:38 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:6015) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tMFC2-0003Lw-Rf for 74738@debbugs.gnu.org; Fri, 13 Dec 2024 18:35:36 -0500 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 81D0D10004A; Fri, 13 Dec 2024 18:35:22 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1734132921; bh=vku2GD+v0sRoMGV6acYc80kZQJjIGqQpwEjTR+CL5+0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=m/4TcvK9JkNyB1bIWmcWJVoSEBmub6Od59oQPjPc/l5OtsHw+SIG8U+9FWz7jbtj6 sActjChGlJTzWJt3wrLAKVUyUxhOPGCdGxnufa6svMgj4bHlMt6WuN3ZrY9eqk3SI+ jgHWG51V2N3B4VJNkg3Zm3MFTAAQL8mFtIlyivh66oOJQVSu9st02wY5H6rgaeVl7E VPi0x10VeeqO9IaZwGstNbleNFKhsNeuEjdzC94Ujgkmr4/gqQe03i6jE978LipFGR yM4iyPxmGbsxJoi+dyqXJO4Rv5dyLVxD1PbdVoED+UTahm4n3A/w9NTBKXyjpgRmhe QLOZmie4xoRQA== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id CF83F100042; Fri, 13 Dec 2024 18:35:21 -0500 (EST) Received: from alfajor (104-195-225-43.cpe.teksavvy.com [104.195.225.43]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 981CC12005A; Fri, 13 Dec 2024 18:35:21 -0500 (EST) From: Stefan Monnier In-Reply-To: (kobarity@gmail.com's message of "Wed, 11 Dec 2024 23:24:34 +0900") Message-ID: References: <868qsqf54x.fsf@gnu.org> Date: Fri, 13 Dec 2024 18:35:20 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.028 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > The mechanism of the hang is still unclear, but I found the cause of > the font-lock malfunction: when using `up-list' to find the > corresponding closing brace for an opening brace in an f-string, if > the format specifier contains "#", the rest of the string is > considered a comment and the search fails. Therefore, it can be > worked around by temporarily binding `parse-sexp-ignore-comments' to > nil, as in the attached patch. Maybe a cleaner solution would be to locally use a different syntax-table (where # doesn't start a comment), but I'm not sure it's worth the trouble. So I installed your patch into `master`, thank you. Maybe we should also temporarily setup a narrowing so `up-list` can't look past `send`. BTW, beside removing the `font-lock-string-face` from the `face` property, `python--font-lock-f-strings` should probably also add a special face for the ":" thingies found (optionally) at the end. > Hangs on gef.py can also be avoided with this patch, but it assumes > that the braces are properly closed. If you remove the closing braces > of expressions containing "#", it will eventually hang. Hmm... Stefan From unknown Sun Jun 22 00:15:17 2025 X-Loop: help-debbugs@gnu.org Subject: bug#74738: 31.0.50; Freezes in Python-mode on some Python file when searching or scrolling Resent-From: kobarity Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 15 Dec 2024 14:28:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74738 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier , rehan malak Cc: Eli Zaretskii , 74738@debbugs.gnu.org Received: via spool by 74738-submit@debbugs.gnu.org id=B74738.1734272875654 (code B ref 74738); Sun, 15 Dec 2024 14:28:03 +0000 Received: (at 74738) by debbugs.gnu.org; 15 Dec 2024 14:27:55 +0000 Received: from [127.0.0.1] (port=50021 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tMpat-00009y-3m for submit@debbugs.gnu.org; Sun, 15 Dec 2024 09:27:54 -0500 Received: from mail-pl1-f182.google.com ([209.85.214.182]:54464) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tMpaj-00009n-KF for 74738@debbugs.gnu.org; Sun, 15 Dec 2024 09:27:30 -0500 Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2163bd70069so33173915ad.0 for <74738@debbugs.gnu.org>; Sun, 15 Dec 2024 06:27:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734272788; x=1734877588; darn=debbugs.gnu.org; h=mime-version:user-agent:references:in-reply-to:subject:cc:to:from :message-id:date:from:to:cc:subject:date:message-id:reply-to; bh=CibiRui5zvNrs7/3gTxcdmgZgCwL3gtKALn1XyZBUBI=; b=IAXhWj+zUefNrbbOtvXmA2V+uU4XjaZeHqSKFdVhSZws/1uf5i6ApqJMNldHhdIcLX XBHkxgadC4OE38zz7AwlJ6BGSMFPWLDWt3+5rJYB2AzSafS4ojtLFAcUK0tBXgi9DeKQ F0zXE1SGbQBsxgmwOO+NeVAiozoPUJbGdfUbnO8rgFzyOjL9yVPn/mBAYAj0zQ7UvwNE 1ntVCCoOx2j98KH4rVgxIBVA2oHNPhlXOzEhDI8ixZxbF4xm34b+k/hPfTHEH6pPBFGr uPWOTE9DaXWFIXttLFp2TTyLSOoLPrQEgZdTbRCvtOvB3sE6LpgmMqZIx/AV9fGUKfBi iZTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734272788; x=1734877588; h=mime-version:user-agent:references:in-reply-to:subject:cc:to:from :message-id:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=CibiRui5zvNrs7/3gTxcdmgZgCwL3gtKALn1XyZBUBI=; b=km1vjbR8yrCvX6EuWrBvJwswrVsJ5bV63RI4mZY1r3WqBX8vgc5DPxmTii2H9hiUEd a/1J5nUns6wkwiGDNPRRuHVqQ2alymi2hpbipqJlxPGEqOKMChfSDcbcy0Lf51wdZFJq 7BqM8aYMCi04scrgFoFd7imXdde+mjDKRE8+9hpfZuzi9w2mX2XmiRnolfXqrnrO5DgV aB38dQPTsk5Iwe2eEgvKC3kt+X/ouyIOPfdE1EfY6e0a31Zf/FaRDTw/Ycp8rnO16VLF kQNhPwwB8W0dGLEC5zkTBkuBVa6KkbbOwjg5X12yattuRUx178iKBqxRv5VjWd32PLEz vjAA== X-Forwarded-Encrypted: i=1; AJvYcCWb5TaE50bFSZ9VpXDFadlbgKjFAE5MNWiP+lMsMxvTkZ+/gQD1LZFXyTWpUElbPfa8veo8jQ==@debbugs.gnu.org X-Gm-Message-State: AOJu0Yw2EZS1M8lVcs7UBDfRF9onGAjIO0uexT71h8WrGDf+2TLxosBQ 7+lqUKq1N/HxdPWbp9FHGbqOKZlQ1/7v580Dk8IE150aLls6qAeJ X-Gm-Gg: ASbGncvAJc/QUtp97GX8LPUh1+aFTgyQfiavEjcXEy7lGxlfP2X7iCZRCRsX61I+nTl UNmC0rpPwruDH1HCwLlqlL1k56CHA0GbzV7fotTdVhO8ujYayUSwYf7mgNi+pl2+HGlDjE7DAsY hsDfXTh3F1cYQdfG9jIQZ+CO9u845s7Y9HPy7E2awQiRe/9BTEALehQGVyuOz967Xbfn/sr9EH2 KYPsxpvzjB7t/5eTSj3p0QDbUArEpIUwsKKhRMXNueI9FGvFXetKZR/YZcogEMvKDHX5eJuUFm1 plnxhRRSGdU= X-Google-Smtp-Source: AGHT+IFN9YM/lZw5BB1j8K3G2P53u3pe3zsagDGTmQiD4K+d2FngKZa8QZcLlKZce6QDM2FlmVgAzw== X-Received: by 2002:a17:903:24e:b0:216:6901:d599 with SMTP id d9443c01a7336-218929a1d39mr136730695ad.13.1734272788450; Sun, 15 Dec 2024 06:26:28 -0800 (PST) Received: from localhost (58x12x133x161.ap58.ftth.ucom.ne.jp. [58.12.133.161]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-218a1e54101sm26790595ad.151.2024.12.15.06.26.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Dec 2024 06:26:27 -0800 (PST) Date: Sun, 15 Dec 2024 23:26:05 +0900 Message-ID: From: kobarity In-Reply-To: References: <868qsqf54x.fsf@gnu.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?Q?Goj=C5=8D?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/31.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: multipart/mixed; boundary="Multipart_Sun_Dec_15_23:26:05_2024-1" X-Spam-Score: 0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --Multipart_Sun_Dec_15_23:26:05_2024-1 Content-Type: text/plain; charset=US-ASCII rehan malak wrote: > thanks kobarity, with your patch, I confirm that : > - I can open gef.py and scroll > - I get the correct font-lock-string-face in the f-string after a "#" in the format Thank you for your confirmation. Stefan Monnier wrote: > > The mechanism of the hang is still unclear, but I found the cause of > > the font-lock malfunction: when using `up-list' to find the > > corresponding closing brace for an opening brace in an f-string, if > > the format specifier contains "#", the rest of the string is > > considered a comment and the search fails. Therefore, it can be > > worked around by temporarily binding `parse-sexp-ignore-comments' to > > nil, as in the attached patch. > > Maybe a cleaner solution would be to locally use a different > syntax-table (where # doesn't start a comment), but I'm not sure it's > worth the trouble. So I installed your patch into `master`, thank you. Thank you. I agree with you about the syntax-table. > Maybe we should also temporarily setup a narrowing so `up-list` can't > look past `send`. > > BTW, beside removing the `font-lock-string-face` from the `face` > property, `python--font-lock-f-strings` should probably also add > a special face for the ":" thingies found (optionally) at the end. > > > Hangs on gef.py can also be avoided with this patch, but it assumes > > that the braces are properly closed. If you remove the closing braces > > of expressions containing "#", it will eventually hang. > > Hmm... Narrowing might improve it, but what about binding `forward-sexp-function' to nil as well, as in the attached patch? It seems to resolve the hang caused by the unbalanced braces in f-strings. 1. wget https://raw.githubusercontent.com/hugsy/gef/refs/heads/main/gef.py 2. sed -i -e 's/\(:#\d*x\)}/\1/g' gef.py 3. emacs -Q gef.py 4. Scroll down the file. I don't think `python-nav-forward-sexp' is necessary here, since the inside of the braces should be an expression, not statements. --Multipart_Sun_Dec_15_23:26:05_2024-1 Content-Type: text/plain; type=patch; name="0001-Fix-hangs-caused-by-unbalanced-braces-in-Python-f-st.patch"; charset=US-ASCII Content-Disposition: attachment; filename="0001-Fix-hangs-caused-by-unbalanced-braces-in-Python-f-st.patch" Content-Transfer-Encoding: 7bit >From bb2c1a3e03416532fb97d6fa7ef276c5feebb356 Mon Sep 17 00:00:00 2001 From: kobarity Date: Sun, 15 Dec 2024 23:02:51 +0900 Subject: [PATCH] Fix hangs caused by unbalanced braces in Python f-strings * lisp/progmodes/python.el (python--font-lock-f-strings): Temporarily bind forward-sexp-function to nil when calling 'up-list'. (Bug#74738) --- lisp/progmodes/python.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 5729b12573f..493eab5e611 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -623,7 +623,8 @@ python--font-lock-f-strings (forward-char 1) ;Just skip over {{ (let ((beg (match-beginning 0)) (end (condition-case nil - (let ((parse-sexp-ignore-comments)) + (let ((forward-sexp-function) + (parse-sexp-ignore-comments)) (up-list 1) (min send (point))) (scan-error send)))) -- 2.43.0 --Multipart_Sun_Dec_15_23:26:05_2024-1-- From unknown Sun Jun 22 00:15:17 2025 X-Loop: help-debbugs@gnu.org Subject: bug#74738: 31.0.50; Freezes in Python-mode on some Python file when searching or scrolling Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 15 Dec 2024 15:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74738 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: kobarity Cc: rehan malak , Eli Zaretskii , 74738@debbugs.gnu.org Received: via spool by 74738-submit@debbugs.gnu.org id=B74738.17342750309496 (code B ref 74738); Sun, 15 Dec 2024 15:04:02 +0000 Received: (at 74738) by debbugs.gnu.org; 15 Dec 2024 15:03:50 +0000 Received: from localhost ([127.0.0.1]:51586 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tMq9t-0002T6-In for submit@debbugs.gnu.org; Sun, 15 Dec 2024 10:03:49 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:44655) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tMq9q-0002Sn-5D for 74738@debbugs.gnu.org; Sun, 15 Dec 2024 10:03:46 -0500 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id BE38580030; Sun, 15 Dec 2024 10:03:39 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1734275014; bh=EgYrKVZAeugh2PqQInDCZjwuL7w645F/GUakz2Jli9s=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=L5jbyuvOMGxh7iI8CTVLZQ08sBwnW0z9I3ccWQuRIyOi7N6OO+4fMD5HMgwgkyymT N6Xx089fVOGs5uTA9JXSXYA5WawQAK1DQj7foLxG6iqydq+SLfWyvNjiWkyOfm1fmz b/S0ffZQd/s/fdbS8FEzxHgiwBlAF3qsalicNIRW9Soxa4cfgOb1PXZdrPCcXdwkqq DtZR2Zk8q+vmB3no2ecX991vN2Z6AsDIGTXdtozKMubfBH1wtvik8OyZsXe2WsK2Bi hsMD8iAzmd8jO2tbQpHP26PC4uEEsbVMMV8WX6uPuFUhxAtOXY8v0to9mzntciR+I0 y+a7mPKLEwebg== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id CE18380152; Sun, 15 Dec 2024 10:03:34 -0500 (EST) Received: from pastel (104-195-225-43.cpe.teksavvy.com [104.195.225.43]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 95FDF12055E; Sun, 15 Dec 2024 10:03:34 -0500 (EST) From: Stefan Monnier In-Reply-To: (kobarity@gmail.com's message of "Sun, 15 Dec 2024 23:26:05 +0900") Message-ID: References: <868qsqf54x.fsf@gnu.org> Date: Sun, 15 Dec 2024 10:03:33 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.041 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) >> > Hangs on gef.py can also be avoided with this patch, but it assumes >> > that the braces are properly closed. If you remove the closing braces >> > of expressions containing "#", it will eventually hang. >> >> Hmm... > > Narrowing might improve it, but what about binding > `forward-sexp-function' to nil as well, as in the attached patch? Oh, of course, yes! Thanks, pushed! Stefan From unknown Sun Jun 22 00:15:17 2025 X-Loop: help-debbugs@gnu.org Subject: bug#74738: 31.0.50; Freezes in Python-mode on some Python file when searching or scrolling Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 21 Dec 2024 09:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74738 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: kobarity@gmail.com, rehan.malak@gmail.com, 74738@debbugs.gnu.org Received: via spool by 74738-submit@debbugs.gnu.org id=B74738.173477467032195 (code B ref 74738); Sat, 21 Dec 2024 09:52:02 +0000 Received: (at 74738) by debbugs.gnu.org; 21 Dec 2024 09:51:10 +0000 Received: from localhost ([127.0.0.1]:45331 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tOw8c-0008N9-CP for submit@debbugs.gnu.org; Sat, 21 Dec 2024 04:51:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:32912) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tOw8Z-0008Mn-Ql for 74738@debbugs.gnu.org; Sat, 21 Dec 2024 04:51:08 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tOw8T-0001Uc-Sb; Sat, 21 Dec 2024 04:51:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=o2VL6BWyMtnOGF5eRJTTsznw9m3H63MDzdNuKyeZtmA=; b=dRIFh5pTv9ck 4BgMDOAIP7G7xjQzVMKqo4EkI5lW9lDqnbPfR+7fXlF5V55HtqRwodnQQLvsk54vy+O8tAv0eByHV PTv2Rhvc8zD0P0ON8XVYJ06iKq5QFiNQcl2Aw16OqbHAUPNfl7hqjEuje9azeB1vixZyE8RCI7n34 mIVZfe8zXpN3kchNL6aMs40iRvWz1WIxXOoVE9k6Nr0oRaZOHYF95WTGKQZZDaTaTGduqoh76ZPce lzj69FIrx0F7LONipDoS2kXUmmlf9K/XRjx2Nb3UrPsf4jo+fHhJE3FsibaPoORq+yWuabJHp7VQJ zCD9W+B1862t+bOfdrhKQw==; Date: Sat, 21 Dec 2024 11:50:58 +0200 Message-Id: <864j2x8iv1.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (message from Stefan Monnier on Sun, 15 Dec 2024 10:03:33 -0500) References: <868qsqf54x.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Stefan Monnier > Cc: rehan malak , Eli Zaretskii , > 74738@debbugs.gnu.org > Date: Sun, 15 Dec 2024 10:03:33 -0500 > > >> > Hangs on gef.py can also be avoided with this patch, but it assumes > >> > that the braces are properly closed. If you remove the closing braces > >> > of expressions containing "#", it will eventually hang. > >> > >> Hmm... > > > > Narrowing might improve it, but what about binding > > `forward-sexp-function' to nil as well, as in the attached patch? > > Oh, of course, yes! > Thanks, pushed! Thanks, should we now close this bug? From unknown Sun Jun 22 00:15:17 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: rehan malak Subject: bug#74738: closed (Re: bug#74738: 31.0.50; Freezes in Python-mode on some Python file when searching or scrolling) Message-ID: References: X-Gnu-PR-Message: they-closed 74738 X-Gnu-PR-Package: emacs Reply-To: 74738@debbugs.gnu.org Date: Sat, 21 Dec 2024 14:22:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1734790922-21702-1" This is a multi-part message in MIME format... ------------=_1734790922-21702-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #74738: 31.0.50; Freezes in Python-mode on some Python file when searching = or scrolling which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 74738@debbugs.gnu.org. --=20 74738: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D74738 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1734790922-21702-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 74738-done) by debbugs.gnu.org; 21 Dec 2024 14:21:43 +0000 Received: from localhost ([127.0.0.1]:45792 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tP0MR-0005dV-9N for submit@debbugs.gnu.org; Sat, 21 Dec 2024 09:21:43 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:27292) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tP0MP-0005dG-AY for 74738-done@debbugs.gnu.org; Sat, 21 Dec 2024 09:21:41 -0500 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id EBF7780962; Sat, 21 Dec 2024 09:21:35 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1734790895; bh=8rPu6pzOEqO6tPkRBl51qpPBCk/rk0XljaHjSsV/ibY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Yq8B+rCsxbUA5A2EiQ+k5sn7wjYs6QbeZJfdMik1ogXhjx0ceeF6OSRHjoEqwnoKb GgP0Az54MEuSYNGbqwPfyMar1PPqmzoi9f8kRqfY7jZHfpqYN9f3KBnS4hVDjElGK0 I7s/2cWYbiH7D+zVOFjhjRLpFjCdLftFmaZPzm6I3gcBe7LOQr1JBoeTRGk4hek+Vw Zzy1yqdYwxlmcB6GjgIKKnQlz2skeMsOREJGtfcrgwIxT4K3ij3SBdvfDPNNpeIBwX PnFuhZrVMsFKUkV9ztAk9eb8xMM1dHsQGoUqWqYp6vU+2ZCvm0kQT9T6p2V7dnOewb JPTV5VEtE6PxQ== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 2C4AA8079A; Sat, 21 Dec 2024 09:21:35 -0500 (EST) Received: from asado (unknown [199.119.74.1]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id DF509120319; Sat, 21 Dec 2024 09:21:34 -0500 (EST) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#74738: 31.0.50; Freezes in Python-mode on some Python file when searching or scrolling In-Reply-To: <864j2x8iv1.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 21 Dec 2024 11:50:58 +0200") Message-ID: References: <868qsqf54x.fsf@gnu.org> <864j2x8iv1.fsf@gnu.org> Date: Sat, 21 Dec 2024 09:21:20 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.217 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 74738-done Cc: 74738-done@debbugs.gnu.org, kobarity@gmail.com, rehan.malak@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Thanks, should we now close this bug? I believe so, yes, closing, Stefan ------------=_1734790922-21702-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 8 Dec 2024 15:00:07 +0000 Received: from localhost ([127.0.0.1]:51369 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKIlQ-0005ve-Ei for submit@debbugs.gnu.org; Sun, 08 Dec 2024 10:00:07 -0500 Received: from lists.gnu.org ([209.51.188.17]:55866) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tKGzN-0008Rx-Tc for submit@debbugs.gnu.org; Sun, 08 Dec 2024 08:06:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tKGxF-0007o6-S9 for bug-gnu-emacs@gnu.org; Sun, 08 Dec 2024 08:04:11 -0500 Received: from mail-vk1-xa2f.google.com ([2607:f8b0:4864:20::a2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tKGxD-0002wR-8c for bug-gnu-emacs@gnu.org; Sun, 08 Dec 2024 08:04:09 -0500 Received: by mail-vk1-xa2f.google.com with SMTP id 71dfb90a1353d-5160f1870f3so385862e0c.0 for ; Sun, 08 Dec 2024 05:04:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733663045; x=1734267845; darn=gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=G2sIsTZFehvl/4crpyGcbdxxJ9krPBKlCTxOM3RzpVE=; b=cRUsyagGJgR0ZWxBrMXe1bwJM7gfweIsvmQdtM0eoKVrf3qDBY+CDVP6H4iqYBMLHO auJ2PkGsWYe8gwfxqvNPX320sP/0dTRMD3O70rgTvt9wia6nrkMUJ6zrWYP4wxU86S43 nSdrxiOL83tVPQZxK9Bmqoe+uw2ybtnA4pc6F/VxnCX1YdwTSLlDnzx4WQ2NYcWx+FkE LpsmveNPs/S63Uq8W+ovlpsGy4VQG9M9x9gJeSACc2WfxPUkRVaVD324yK0ivqf4S2xb aK1q7HJmqHq4WHaubDyodLo/YTiO+oCbcU7LpsLFOZ2WkP5yKZT38sepLk9Brgk6BN0G fqLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733663045; x=1734267845; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=G2sIsTZFehvl/4crpyGcbdxxJ9krPBKlCTxOM3RzpVE=; b=AvxNlc6gtOSJWJcOnBvQU2dAJj84Xd+ad/3Cn1YZE6RFPjtPPr6QJta9l3dzNV8Par Hq/16g25l4ZOCDkkL5rYBFxwH+Fswc9DhS1QGuOZW6KLhpZtCl/CYEkujgCuB1LrmdC+ 2B52VXy7D/D1VojQbr5/AITLGv6lijTFj7338U3iYlsZ4A+b0ZGXQD+2D6ajItErdP4C 1LAuj+0hsUe0h/AvrLgD4TMXeyp0tJMZ8Xlre5qDV4v9hYB1FE1LI856JO0+J4kjuW13 UKot3Bs0aCJp8xvvZzS8XyJ9HirVrFYPse6aXnsjstCNyv+DuzDkYFZgLcN3bOeC+k9y +FFw== X-Gm-Message-State: AOJu0YwV+Gr+2/qmopWsEBMvdfWIT/lO1x5PJAO9viRt3dABxZff3uKh g8nIMBZCsnyrDDN9hmfGdKPwo7U7pdfLnFZT5TsLoSRcdHwzE3hJobu+r4o2mSOoTCyndKOOcX+ Km9oGAgRojo3Qjc7ZNg9gcD57BjNEavWn X-Gm-Gg: ASbGnctSLHZp56F+jDPgSDZ4zKhw7ixEgjqsfggAPXdTqa7OGv5AH+WKQ+N0qGe0dBf q+6kM9P9LgdlbBT6PVKvY0P/eX0WPWdgx X-Google-Smtp-Source: AGHT+IFQqvyrjZxv5CvdhZeTPdJL6yayeZhrpC6zGfXF+1maYVnEOzErf9IU9Za91zJoDw10g2f9u1D09hArNs8R2rc= X-Received: by 2002:a05:6122:c81:b0:515:3bfb:d421 with SMTP id 71dfb90a1353d-515fca3498amr8011815e0c.6.1733663044861; Sun, 08 Dec 2024 05:04:04 -0800 (PST) MIME-Version: 1.0 From: rehan malak Date: Sun, 8 Dec 2024 14:05:36 +0100 Message-ID: Subject: 31.0.50; Freezes in Python-mode on some Python file when searching or scrolling To: bug-gnu-emacs@gnu.org Content-Type: multipart/alternative; boundary="000000000000f308ff0628c1e1b6" Received-SPF: pass client-ip=2607:f8b0:4864:20::a2f; envelope-from=rehan.malak@gmail.com; helo=mail-vk1-xa2f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -0.6 (/) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sun, 08 Dec 2024 10:00:02 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.6 (-) --000000000000f308ff0628c1e1b6 Content-Type: text/plain; charset="UTF-8" Hi, I can reproduce systematically this freeze dealing with a 10000lines Python file : wget https://raw.githubusercontent.com/hugsy/gef/refs/heads/main/gef.py emacs -Q gef.py PageDown several times or scrolling with the mouse Emacs freezes, Ctrl-g not working, CPU 100% It works also by searching : Ctrl-s show RET then Ctrl-s several times With a minimal .emacs : (set debug-on-error t) (set debug-on-quit t) and before scrolling M-x profiler-start RET then in an external terminal pkill -SIGUSR2 emacs I get the backtrace : Debugger entered--entering a function: * #f(compiled-function () #)() syntax-ppss() python-syntax-context-type() python-nav-forward-block(-1) python-nav-backward-block() python-nav-beginning-of-block() python-nav-end-of-block() python-info-statement-ends-block-p() python-info-end-of-block-p() python-nav--forward-sexp(1 nil nil) python-nav-forward-sexp(1) forward-sexp(1) up-list(1) python--font-lock-f-strings(30419) font-lock-fontify-keywords-region(28914 30419 nil) font-lock-default-fontify-region(28914 30414 nil) font-lock-fontify-region(28914 30414) #f(compiled-function (fun) #)(font-lock-fontify-region) run-hook-wrapped(#f(compiled-function (fun) #) font-lock-fontify-region) jit-lock--run-functions(28914 30414) jit-lock-fontify-now(28914 30414) jit-lock-function(28914) and can look at profiler report M-x profiler-stop M-x profiler-report showing time spent in syntax-ppss 17770 88% - jit-lock-function 17770 88% - jit-lock-fontify-now 17770 88% - jit-lock--run-functions 17770 88% - run-hook-wrapped 17770 88% - # 17770 88% - font-lock-fontify-region 17770 88% - font-lock-default-fontify-region 17690 87% - font-lock-fontify-keywords-region 17678 87% - python--font-lock-f-strings 17674 87% - up-list 17674 87% - forward-sexp 17674 87% - python-nav-forward-sexp 17674 87% - python-nav--forward-sexp 9253 45% - python-info-end-of-block-p 9245 45% - python-info-statement-ends-block-p 9221 45% - python-nav-end-of-block 8609 42% - python-nav-beginning-of-block 8557 42% - python-nav-backward-block 8557 42% - python-nav-forward-block 8005 39% - python-syntax-context-type 7997 39% - syntax-ppss 7097 35% parse-partial-sexp 753 3% + # 376 1% + python-nav-beginning-of-statement 132 0% re-search-backward 24 0% looking-at 28 0% current-indentation 8 0% + python-nav-beginning-of-statement 4 0% python-info-current-line-empty-p 4 0% + python-info-current-line-comment-p 604 2% + python-nav-end-of-statement 4 0% + python-info-current-line-comment-p 4 0% current-indentation 24 0% + python-nav-end-of-statement 8 0% + python-info-end-of-statement-p 8178 40% - python-info-statement-ends-block-p 8150 40% - python-nav-end-of-block 7754 38% - python-nav-beginning-of-block 7738 38% - python-nav-backward-block 7734 38% - python-nav-forward-block 7178 35% - python-syntax-context-type 7174 35% - syntax-ppss 6978 34% parse-partial-sexp 8 0% make-closure 8 0% # 4 0% syntax-table 4 0% syntax-ppss--update-stats 412 2% + python-nav-beginning-of-statement 92 0% re-search-backward 44 0% looking-at 12 0% current-indentation 4 0% looking-at 380 1% + python-nav-end-of-statement 16 0% + python-util-forward-comment 28 0% + python-nav-end-of-statement 151 0% + python-nav-end-of-block 28 0% + python-info-beginning-of-block-p 24 0% + python-info-end-of-statement-p 20 0% + python-info-beginning-of-statement-p 8 0% + python-syntax-context-type 8 0% + python-info-statement-starts-block-p 4 0% + syntax-ppss 8 0% + # 4 0% + # 80 0% + font-lock-fontify-syntactically-region 2279 11% Automatic GC 73 0% + redisplay_internal (C function) 40 0% + command-execute 8 0% + ... 4 0% + mouse--click-1-maybe-follows-link other people talking about python/profiling/syntax-ppss : https://www.reddit.com/r/emacs/comments/z0oye9/emacs_freezes_when_opening_a_python_file/ https://www.reddit.com/r/emacs/comments/9h7onq/large_python_files_hanging_with_an_unmatched_quote/ Please tell me how I can help ? Please tell me if there is a workaround without losing python syntax color ? Thanks Rehan In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.43, cairo version 1.18.2) of 2024-12-08 built on cndl Repository revision: b953bcb17047998c9e41cede7c5e5ffec22209b2 Repository branch: master System Description: Debian GNU/Linux trixie/sid Configured using: 'configure --prefix=/home/jean/local/emacs --with-pgtk' Configured features: CAIRO DBUS FREETYPE GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PGTK PNG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS WEBP XIM GTK3 ZLIB Important settings: value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: Python Minor modes in effect: tooltip-mode: t global-eldoc-mode: t eldoc-mode: t show-paren-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 minibuffer-regexp-mode: t line-number-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message mailcap yank-media puny dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068 epg-config gnus-util text-property-search 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 cl-seq python rx project byte-opt gv bytecomp byte-compile compat pcase treesit comint subr-x ansi-osc ring cl-loaddefs cl-lib ansi-color rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/pgtk-win pgtk-win term/common-win touch-screen pgtk-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-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 font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic indonesian philippine 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 emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads dbusbind inotify dynamic-setting system-font-setting font-render-setting cairo gtk pgtk multi-tty move-toolbar make-network-process emacs) Memory information: ((conses 16 60995 13527) (symbols 48 7517 0) (strings 32 19122 1493) (string-bytes 1 515162) (vectors 16 13554) (vector-slots 8 145472 8433) (floats 8 26 2) (intervals 56 436 0) (buffers 984 12)) --000000000000f308ff0628c1e1b6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,
I can reproduce systematically this freeze dealing = with a 10000lines
Python file :

wget https://raw.githubuserco= ntent.com/hugsy/gef/refs/heads/main/gef.py
emacs -Q gef.py

Pa= geDown several times or scrolling with the mouse

Emacs freezes, Ctrl= -g not working, CPU 100%

It works also by searching : Ctrl-s show RE= T
then Ctrl-s several times




With a minimal .emacs :
(set debug-on-error t)
(set debug-on-quit t)

and before s= crolling

M-x profiler-start RET

then in an external terminal<= br>
pkill -SIGUSR2 emacs

I get the backtrace :

Debugger en= tered--entering a function:
* #f(compiled-function () #<bytecode -0x1= 79dcd1db31182ae>)()
=C2=A0 syntax-ppss()
=C2=A0 python-syntax-cont= ext-type()
=C2=A0 python-nav-forward-block(-1)
=C2=A0 python-nav-back= ward-block()
=C2=A0 python-nav-beginning-of-block()
=C2=A0 python-nav= -end-of-block()
=C2=A0 python-info-statement-ends-block-p()
=C2=A0 py= thon-info-end-of-block-p()
=C2=A0 python-nav--forward-sexp(1 nil nil)=C2=A0 python-nav-forward-sexp(1)
=C2=A0 forward-sexp(1)
=C2=A0 up-l= ist(1)
=C2=A0 python--font-lock-f-strings(30419)
=C2=A0 font-lock-fon= tify-keywords-region(28914 30419 nil)
=C2=A0 font-lock-default-fontify-r= egion(28914 30414 nil)
=C2=A0 font-lock-fontify-region(28914 30414)
= =C2=A0 #f(compiled-function (fun) #<bytecode -0x8a96d65e1315e71>)(fon= t-lock-fontify-region)
=C2=A0 run-hook-wrapped(#f(compiled-function (fun= ) #<bytecode -0x8a96d65e1315e71>) font-lock-fontify-region)
=C2=A0= jit-lock--run-functions(28914 30414)
=C2=A0 jit-lock-fontify-now(28914 = 30414)
=C2=A0 jit-lock-function(28914)

and can look at profiler r= eport

M-x profiler-stop
M-x profiler-report

showing time s= pent in syntax-ppss


=C2=A0 =C2=A0 =C2=A0 =C2=A017770 =C2=A088% -= jit-lock-function
=C2=A0 =C2=A0 =C2=A0 =C2=A017770 =C2=A088% =C2=A0- ji= t-lock-fontify-now
=C2=A0 =C2=A0 =C2=A0 =C2=A017770 =C2=A088% =C2=A0 - j= it-lock--run-functions
=C2=A0 =C2=A0 =C2=A0 =C2=A017770 =C2=A088% =C2=A0= =C2=A0- run-hook-wrapped
=C2=A0 =C2=A0 =C2=A0 =C2=A017770 =C2=A088% =C2= =A0 =C2=A0 - #<byte-code-function FA0>
=C2=A0 =C2=A0 =C2=A0 =C2=A0= 17770 =C2=A088% =C2=A0 =C2=A0 =C2=A0- font-lock-fontify-region
=C2=A0 = =C2=A0 =C2=A0 =C2=A017770 =C2=A088% =C2=A0 =C2=A0 =C2=A0 - font-lock-defaul= t-fontify-region
=C2=A0 =C2=A0 =C2=A0 =C2=A017690 =C2=A087% =C2=A0 =C2= =A0 =C2=A0 =C2=A0- font-lock-fontify-keywords-region
=C2=A0 =C2=A0 =C2= =A0 =C2=A017678 =C2=A087% =C2=A0 =C2=A0 =C2=A0 =C2=A0 - python--font-lock-f= -strings
=C2=A0 =C2=A0 =C2=A0 =C2=A017674 =C2=A087% =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0- up-list
=C2=A0 =C2=A0 =C2=A0 =C2=A017674 =C2=A087% =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 - forward-sexp
=C2=A0 =C2=A0 =C2=A0 =C2= =A017674 =C2=A087% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- python-nav-fo= rward-sexp
=C2=A0 =C2=A0 =C2=A0 =C2=A017674 =C2=A087% =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 - python-nav--forward-sexp
=C2=A0 =C2=A0 =C2=A0= =C2=A0 9253 =C2=A045% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- py= thon-info-end-of-block-p
=C2=A0 =C2=A0 =C2=A0 =C2=A0 9245 =C2=A045% =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 - python-info-statement-ends-= block-p
=C2=A0 =C2=A0 =C2=A0 =C2=A0 9221 =C2=A045% =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- python-nav-end-of-block
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 8609 =C2=A042% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 - python-nav-beginning-of-block
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 8557 =C2=A042% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0- python-nav-backward-block
=C2=A0 =C2=A0 =C2=A0 =C2=A0 8557 =C2= =A042% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 - pyt= hon-nav-forward-block
=C2=A0 =C2=A0 =C2=A0 =C2=A0 8005 =C2=A039% =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- python-synt= ax-context-type
=C2=A0 =C2=A0 =C2=A0 =C2=A0 7997 =C2=A039% =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 - syntax-ppss
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 7097 =C2=A035% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0parse-partial-sexp
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0753 =C2=A0 3% =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0+ #<byte-code-function = A23>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0376 =C2=A0 1% =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0+ python-nav-beginni= ng-of-statement
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0132 =C2=A0 0% =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0re-sea= rch-backward
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 24 =C2=A0 0% =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0looking-a= t
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 28 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0current-indentation
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A08 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0+ python-nav-beginning-of-statement=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A04 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0python-info-current-line-e= mpty-p
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A04 =C2=A0 0% =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0+ python-info-current-l= ine-comment-p
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0604 =C2=A0 2% =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 + python-nav-end-of-statement=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A04 =C2=A0 0% =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 + python-info-current-line-comment-p=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A04 =C2=A0 0% =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 current-indentation
=C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 24 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0+ python-nav-end-of-statement
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A08 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 + python-info-end-of-statement-p
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = 8178 =C2=A040% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- python-inf= o-statement-ends-block-p
=C2=A0 =C2=A0 =C2=A0 =C2=A0 8150 =C2=A040% =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 - python-nav-end-of-block
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 7754 =C2=A038% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0- python-nav-beginning-of-block
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 7738 =C2=A038% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 - python-nav-backward-block
=C2=A0 =C2=A0 =C2=A0 =C2=A0 7734 = =C2=A038% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- p= ython-nav-forward-block
=C2=A0 =C2=A0 =C2=A0 =C2=A0 7178 =C2=A035% =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 - python-syntax= -context-type
=C2=A0 =C2=A0 =C2=A0 =C2=A0 7174 =C2=A035% =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- syntax-ppss
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 6978 =C2=A034% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 parse-partial-sexp
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A08 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 make-closure
=C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A08 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 #<byte-code-function B1E>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A04 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 syntax-table
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A04 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 syntax-ppss--update= -stats
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0412 =C2=A0 2% =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 + python-nav-beginning-of-sta= tement
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 92 =C2=A0 0% =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 re-search-backward
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 44 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 looking-at
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 12 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 current-indentation
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A04 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 looking-at
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0380 =C2=A0 1% = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0+ python-nav-end-of-= statement
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 16 =C2=A0 0% =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0+ python-util-forward-comment
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 28 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 + python-nav-end-of-statement
=C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0151 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0+ python-nav-end-of-block
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 28 =C2= =A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0+ python-info-beginn= ing-of-block-p
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 24 =C2=A0 0% =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0+ python-info-end-of-statement-p=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 20 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0+ python-info-beginning-of-statement-p
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A08 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0+ python-syntax-context-type
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A08 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0+ python-info-statement-starts-block-p
=C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A04 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0+ syntax-ppss=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A08 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0= =C2=A0 + #<byte-code-function 7E0>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A04 =C2=A0 0% =C2=A0 =C2=A0 =C2=A0 =C2=A0 + #<byte-code-funct= ion 740>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 80 =C2=A0 0% =C2=A0 =C2= =A0 =C2=A0 =C2=A0+ font-lock-fontify-syntactically-region
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 2279 =C2=A011% =C2=A0 Automatic GC
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 73 =C2=A0 0% + redisplay_internal (C function)
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 40 =C2=A0 0% + command-execute
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A08 =C2=A0 0% + ...
=C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A04 =C2=A0 0% + mouse--click-1-maybe-follows-link

other = people talking about python/profiling/syntax-ppss :

https://www.reddit.com/r/emacs/comments/z0oye9/emacs_freezes_when= _opening_a_python_file/
https://= www.reddit.com/r/emacs/comments/9h7onq/large_python_files_hanging_with_an_u= nmatched_quote/

Please tell me how I can help ?

Please te= ll me if there is a workaround without losing python syntax color ?

= Thanks

Rehan



In GNU Emacs 31.0.50 (build 1, x86_64-pc= -linux-gnu, GTK+ Version
=C2=A03.24.43, cairo version 1.18.2) of 2024-12= -08 built on cndl
Repository revision: b953bcb17047998c9e41cede7c5e5ffec= 22209b2
Repository branch: master
System Description: Debian GNU/Linu= x trixie/sid

Configured using:
=C2=A0'configure --prefix=3D/h= ome/jean/local/emacs --with-pgtk'

Configured features:
CAIRO = DBUS FREETYPE GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG LIBSELINUX
LIBXML2= MODULES NOTIFY INOTIFY PDUMPER PGTK PNG SECCOMP SOUND THREADS
TIFF TOOL= KIT_SCROLL_BARS WEBP XIM GTK3 ZLIB

Important settings:
=C2=A0 val= ue of $LANG: en_US.UTF-8
=C2=A0 value of $XMODIFIERS: @im=3Dibus
=C2= =A0 locale-coding-system: utf-8-unix

Major mode: Python

Minor= modes in effect:
=C2=A0 tooltip-mode: t
=C2=A0 global-eldoc-mode: t<= br>=C2=A0 eldoc-mode: t
=C2=A0 show-paren-mode: t
=C2=A0 electric-ind= ent-mode: t
=C2=A0 mouse-wheel-mode: t
=C2=A0 tool-bar-mode: t
=C2= =A0 menu-bar-mode: t
=C2=A0 file-name-shadow-mode: t
=C2=A0 global-fo= nt-lock-mode: t
=C2=A0 font-lock-mode: t
=C2=A0 blink-cursor-mode: t<= br>=C2=A0 minibuffer-regexp-mode: t
=C2=A0 line-number-mode: t
=C2=A0= transient-mark-mode: t
=C2=A0 auto-composition-mode: t
=C2=A0 auto-e= ncryption-mode: t
=C2=A0 auto-compression-mode: t

Load-path shado= ws:
None found.

Features:
(shadow sort mail-extr emacsbug mess= age mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec pass= word-cache epa derived epg rfc6068
epg-config gnus-util text-property-se= arch time-date mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbr= ev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail= -prsvr mail-utils cl-seq python
rx project byte-opt gv bytecomp byte-com= pile compat pcase treesit comint
subr-x ansi-osc ring cl-loaddefs cl-lib= ansi-color rmc iso-transl
tooltip cconv eldoc paren electric uniquify e= diff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/pgtk-win pgtk-= win term/common-win
touch-screen pgtk-dnd tool-bar dnd fontset image reg= exp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode pro= g-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer= select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-co= lors
frame minibuffer nadvice seq simple cl-generic indonesian philippin= e
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet la= o
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czecheuropean ethiopic indian cyrillic chinese composite emoji-zwj charscriptcharprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosurecl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
fi= les window text-properties overlay sha1 md5 base64 format env
code-pages= mule custom widget keymap hashtable-print-readable backquote
threads db= usbind inotify dynamic-setting system-font-setting
font-render-setting c= airo gtk pgtk multi-tty move-toolbar
make-network-process emacs)

= Memory information:
((conses 16 60995 13527) (symbols 48 7517 0) (string= s 32 19122 1493)
=C2=A0(string-bytes 1 515162) (vectors 16 13554)
=C2= =A0(vector-slots 8 145472 8433) (floats 8 26 2) (intervals 56 436 0)
=C2= =A0(buffers 984 12))
--000000000000f308ff0628c1e1b6-- ------------=_1734790922-21702-1--