From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Dynerman Subject: Emacs hangs while loading org file with python blocks Date: Tue, 06 Dec 2016 17:41:57 -0800 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cERFE-0005Mg-3g for emacs-orgmode@gnu.org; Tue, 06 Dec 2016 20:42:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cERFA-0001Be-5r for emacs-orgmode@gnu.org; Tue, 06 Dec 2016 20:42:04 -0500 Received: from poitras.block-party.net ([107.170.248.157]:56442) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cERF9-0001BO-QL for emacs-orgmode@gnu.org; Tue, 06 Dec 2016 20:42:00 -0500 Received: from CIVIC-TV.local (dhcp-169-229-244-81.lips.berkeley.edu [169.229.244.81]) by poitras.block-party.net (Postfix) with ESMTPSA id 876CD12004C for ; Tue, 6 Dec 2016 17:41:57 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Dear list, For several months I've been encountering a frustrating bug. My emacs hangs while initially loading an org file with ~3000 lines and around two dozen python blocks. If I press C-g during the lockup, emacs wakes up and the file is loaded. The hang does not re-occur after happening on initial load - the bug will reoccur only if I restart emacs and load the file again. The hang seems to be related to fontifying the python blocks: after I abort with C-g, some blocks will be unfontified. I previously emailed the list about this bug (Wed, 17 Aug 2016, subject 'Emacs hangs while loading .org file'), but didn't have an easy way to reproduce the problem. I've now managed to extract a minimal org file that reproduces the hang: #+BEGIN_SRC python """xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx""" #+END_SRC #+BEGIN_SRC python class x: def x(self): """ """ pass #+END_SRC To reproduce: 1) Save above as bug.org 2) Open a fresh emacs process, and C-x f bug.org 3) Observe emacs is unresponsive. I've let it run as long as 30 mins without any change. I am able to reproduce with emacs -Q, only executing the following in *scratch*: (add-to-list 'load-path "/usr/local/share/emacs/site-lisp/org") ;; org from git installed here (require 'org) This is with the latest org code from git (release_9.0-132-gd65aa3). The bug does NOT occur with org 8.2.10. I've been encountering this bug for several months, but unfortunately I don't remember exactly when I first saw it. I'm running GNU Emacs 25.1.1 (x86_64-apple-darwin15.6.0, Carbon Version 157 AppKit 1404.47) of 2016-11-24. I'm mystified as to what's going on here. It seems that removing any of the python code in the example above causes the bug to disappear, but I have no clue what the problem might be. I've attached a profiler report captured during the hang. Here is the relevant part: - org-src-font-lock-fontify-block 17419 46% - org-font-lock-ensure 17240 45% - # 17240 45% - font-lock-default-fontify-buffer 17240 45% - font-lock-fontify-region 17240 45% - font-lock-default-fontify-region 17240 45% - font-lock-fontify-syntactically-region 17240 45% - python-font-lock-syntactic-face-function 17240 45% - python-info-docstring-p 17240 45% - python-nav-backward-sexp 17240 45% - python-nav-forward-sexp 17240 45% - python-nav--forward-sexp 17240 45% - python-info-end-of-block-p 17240 45% - python-info-end-of-statement-p 17240 45% - python-nav-end-of-statement 15444 41% syntax-ppss 8641 22% It looks like emacs is getting stuck navigating the python blocks during fontification. The last org-mode call appears to be (org-font-lock-ensure). If anyone has any suggestions on how to fix this, I'd be very interested to hearthem - I'm working with larger and larger org files containing python code, so I'm encountering this bug frequently. Thank you very much, David --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=fontify-bug-profile Content-Transfer-Encoding: base64 KyAuLi4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgIDE5NTYyICA1MSUKKyByZWRpc3BsYXlfaW50ZXJuYWwgKEMgZnVuY3Rpb24pICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgIDE3NDIwICA0NiUKKyBjb21tYW5kLWV4ZWN1dGUgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgNjU4ICAgMSUKKyB0 aW1lci1ldmVudC1oYW5kbGVyICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICA5ICAgMCUK --=-=-=--