From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: John Shahid Newsgroups: gmane.emacs.bugs Subject: bug#32201: 27.0.50; setenv should not change match-data Date: Wed, 18 Jul 2018 19:18:33 +0000 Message-ID: <87h8kwe4ja.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1531941493 10877 195.159.176.226 (18 Jul 2018 19:18:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 18 Jul 2018 19:18:13 +0000 (UTC) To: 32201@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 18 21:18:09 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ffrxd-0002dI-8X for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Jul 2018 21:18:05 +0200 Original-Received: from localhost ([::1]:38022 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffrzk-00058J-9c for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Jul 2018 15:20:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43655) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffrzZ-00058B-DV for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2018 15:20:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffrzW-0001fx-38 for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2018 15:20:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42162) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ffrzV-0001fQ-UV for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2018 15:20:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ffrzV-0004qL-NP for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2018 15:20:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: John Shahid Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 18 Jul 2018 19:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 32201 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.153194154418543 (code B ref -1); Wed, 18 Jul 2018 19:20:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 18 Jul 2018 19:19:04 +0000 Original-Received: from localhost ([127.0.0.1]:47180 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ffrya-0004p1-0X for submit@debbugs.gnu.org; Wed, 18 Jul 2018 15:19:04 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:52449) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ffryY-0004oV-7O for submit@debbugs.gnu.org; Wed, 18 Jul 2018 15:19:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffryR-0008Vk-I5 for submit@debbugs.gnu.org; Wed, 18 Jul 2018 15:18:57 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:40017) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ffryR-0008Ve-EG for submit@debbugs.gnu.org; Wed, 18 Jul 2018 15:18:55 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ffryP-0004OR-KZ for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2018 15:18:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ffryM-0008PS-Ba for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2018 15:18:53 -0400 Original-Received: from mail-qt0-x233.google.com ([2607:f8b0:400d:c0d::233]:44127) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ffryM-0008Oz-4s for bug-gnu-emacs@gnu.org; Wed, 18 Jul 2018 15:18:50 -0400 Original-Received: by mail-qt0-x233.google.com with SMTP id b15-v6so5066781qtp.11 for ; Wed, 18 Jul 2018 12:18:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=gpWW/fL+NmvBs5wrA60baGEtZiNnLcGd3t+aF8ufeH0=; b=PUVHyarXtEbbDa8IJEfFoKLJt3P6X0KGMLwRUtBaUPM5D/wnoEkzo5fXNAqT7TEv6L Tam6eHDR3y0J4yR2xoYc/iHNT0Ep1sSQcwrFK3cSBL1g2zE64Xif/Um+5qb6mdgWnGjO DeMd/foCoTjTHUKQJUf8fo+By/jvjmhGZRB9LxeSaVPIE1YuxGL8zneDQc1rqOWYL+hP 71msc5Z3okbDxHWB4oUeX6mA0eoKvOf1ZialDJTUKVMbUEvKqeBVwpMrXWBTGhFqHtQ1 PyZOmUwmGh/aeDd4YWlVsNvxJL/j4FsDEaV0rjmfvdDjji4VnwSj9EOW+sXBZkcJ07mO fIQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=gpWW/fL+NmvBs5wrA60baGEtZiNnLcGd3t+aF8ufeH0=; b=L3LlAlbdw7U6sf9+xKFxbt5e5kVaXIgNw0wmiBVpLJ6eV9lgPvQPQ5yPVlKgWmOIA6 RbMafqLYJL7ZIWc3qBZtMOKzwLesrUNbUZiSMJ3UAVyZD79ipql1wEpc8+Nsv4hAmwVJ L4QQF0kfX56+Q3dJDV5xoNaQwjoWTPSupumh90sx7mGzwAbD2I2toDOy8BO760qpXH69 +eXzRoF2NJSVICQYcWXeMyHlMNJZ3J9eHuEORWZnshlQ2+Ok6sn5Jg/CuQe63EztXNjW 1Q/typlOeioXbw/U/4cv3BpNTjDqY3nqGGWd8W6FjbFA45kAHEPUYWl6+8pubOzDNiy2 f8Mw== X-Gm-Message-State: AOUpUlHrqn7JVYY5a2Pd0uWTvku1cHiAlR3RXo3a5xIKUo/H+aJG1boh bxsaULNVfbY0bKid1aZEnqGYYk+6 X-Google-Smtp-Source: AAOMgpfqNZS14zDefNs+ta6MLPUFpoRc9bxgAwpUu2fYTeMWrmFtPWFMjXBLX/b98XlK+As3xSN5UA== X-Received: by 2002:a0c:df91:: with SMTP id w17-v6mr7920737qvl.39.1531941529074; Wed, 18 Jul 2018 12:18:49 -0700 (PDT) Original-Received: from 8a803f88ebe0 (cpe-184-152-55-93.nyc.res.rr.com. [184.152.55.93]) by smtp.gmail.com with ESMTPSA id f17-v6sm2577068qtp.1.2018.07.18.12.18.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 12:18:48 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:148643 Archived-At: I have been running into a weird issue lately due to a 'buffer-list-update-hook' that I added in my init.el file. The hook is shown below: (add-hook 'buffer-list-update-hook (lambda () (when (equal major-mode 'go-mode) (unless (boundp 'gopath) (if-let ((root (locate-dominating-file buffer-file-name ".envrc"))) (setq-local gopath (expand-file-name root)) (setq-local gopath nil))) (and gopath (save-match-data (setenv "GOPATH" gopath)))))) The idea of this hook is to set some env variable based on the current buffer. Changing process-environment isn't sufficient since some minor modes I'm using start processes in separate buffers. The problem seems to happen when all of the suddent 'find-file' will start openning weird files. For example, if I'm currently viewing "~/foo/bar.txt" and use 'C-x C-f' the default file name will be "~/foo/~jvshahid/foo/bar.txt". After some debugging it turns out that the following will happen which cause the match-data to be corrupted: 1. find-file calls abbreviate-file-name 2. abbreviate-file-name calls (expand-file-name "~") 3. expand-file-name runs the buffer-list-update-hook (unknown why) 4. the hook will use setenv which messes up the match-data 5. abbreviate-file-name resumes and use the incorrect match-data and return an invalid path I don't know why '3' is happening. This usually doesn't happen in a new Emacs session, only randomly after using Emacs for a while. May be it has something to do with file name handlers, the debugger doesn't show any function calls between 'expand-file-name' and 'run-hooks(buffer-list-update-hook)'. I also used '(find-file-name-handler default-directory 'expand-file-name)' but got back nil. Usually Emacs gets in a weird state at this point and things like 'buffer-list' starts throwing errors about 'max-lisp-eval-depth'. I usually have to set 'buffer-list-update-hook' to 'nil' before being able to gain control. It is worth noting that I saw around 1000 *code-conversion-work* buffers in my Emacs session. In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu) of 2018-07-03 built on f388f63bdd5d Repository revision: 893e62ee7e3630c981adb3efa39ef409500d7657 System Description: Ubuntu 16.04.4 LTS Recent messages: Quit [2 times] [mu4e] Started mu4e with 14071 messages in store [mu4e] Contacts received: 4758 [mu4e] Found 327 matching messages Mark saved where search started [mu4e] Include-related turned off [mu4e] Found 471 matching messages Mark set Quit [2 times] Making completion list... Configured using: 'configure --without-x' Configured features: SOUND NOTIFY GNUTLS LIBXML2 ZLIB THREADS Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: mu4e-headers Minor modes in effect: hl-line-mode: t global-auto-complete-mode: t global-display-line-numbers-mode: t show-paren-mode: t display-time-mode: t display-battery-mode: t global-auto-revert-mode: t xterm-mouse-mode: t winner-mode: t flx-ido-mode: t straight-use-package-mode: t straight-package-neutering-mode: t tooltip-mode: t global-eldoc-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t buffer-read-only: t column-number-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: /home/jvshahid/.emacs.d/straight/build/seq/seq hides /usr/local/share/emacs/27.0.50/lisp/emacs-lisp/seq /home/jvshahid/.emacs.d/straight/build/cl-lib/cl-lib hides /usr/local/share/emacs/27.0.50/lisp/emacs-lisp/cl-lib Features: (shadow sort mail-extr emacsbug misearch multi-isearch org-mu4e org-element avl-tree generator org org-macro org-footnote org-pcomplete pcomplete org-list org-faces org-entities noutline outline easy-mmode org-version ob-emacs-lisp ob ob-tangle org-src ob-ref ob-lob ob-table ob-keys ob-exp ob-comint ob-core ob-eval org-compat org-macs org-loaddefs mu4e desktop frameset mu4e-speedbar speedbar sb-image ezimage dframe mu4e-main mu4e-view cal-menu calendar cal-loaddefs browse-url gnus-art mm-uu mml2015 mm-view mml-smime smime dig mailcap gnus-sum gnus-group gnus-undo gnus-start gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo parse-time gnus-spec gnus-int gnus-range gnus-win gnus nnheader wid-edit mu4e-headers mu4e-compose mu4e-context mu4e-draft mu4e-actions rfc2368 smtpmail auth-source eieio eieio-core eieio-loaddefs sendmail mu4e-mark mu4e-message flow-fill mu4e-proc mu4e-utils doc-view jka-compr image-mode mu4e-lists mu4e-vars message rmc puny format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils mailheader hl-line fringe cl mu4e-meta term/screen term/xterm xterm dired-aux server cl-seq parinfer-ext paredit parinfer ediff-merg ediff-wind ediff-diff ediff-mult ediff-help ediff-init ediff-util ediff mode-local parinferlib flycheck json map find-func rx dash flymake-proc flymake mwheel compile comint regexp-opt ansi-color warnings thingatpt auto-complete-config auto-complete popup elec-pair rect dired-x dired dired-loaddefs display-line-numbers time-date paren time image battery cus-start cus-load autorevert filenotify xt-mouse edmacro kmacro winner ring flx-ido advice flx ido seq seq-25 byte-opt edit-indirect-autoloads parinfer-autoloads ginkgo-mode-autoloads pianobar-autoloads concourse-mode-autoloads hierarchy-autoloads company-lsp-autoloads company-autoloads lsp-ui-autoloads dash-functional-autoloads lsp-java-autoloads lsp-mode-autoloads flx-ido-autoloads flx-autoloads wgrep-autoloads ac-cider-autoloads request-autoloads helm-autoloads helm-core-autoloads paredit-autoloads flycheck-clojure-autoloads flycheck-autoloads cider-autoloads sesman-autoloads seq-autoloads spinner-autoloads queue-autoloads clojure-mode-autoloads go-rename-autoloads ace-window-autoloads avy-autoloads dockerfile-mode-autoloads s-autoloads yasnippet-snippets-autoloads yasnippet-autoloads go-autocomplete-autoloads auto-complete-autoloads go-eldoc-autoloads protobuf-mode-autoloads markdown-mode-autoloads go-guru-autoloads yaml-mode-autoloads etags-select-autoloads magit-autoloads magit-popup-autoloads git-commit-autoloads with-editor-autoloads ghub-autoloads dash-autoloads async-autoloads projectile-autoloads pkg-info-autoloads epl-autoloads go-mode-autoloads debbugs-autoloads finder-inf popup-autoloads cl-lib-autoloads straight-autoloads info tool-bar cl-extra help-mode easymenu straight subr-x straight-compat cl-macs gv cl-loaddefs cl-lib bytecomp byte-compile cconv mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer select mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote inotify multi-tty make-network-process emacs) Memory information: ((conses 16 364700 312163) (symbols 48 41281 1) (miscs 40 121 416) (strings 32 120184 49417) (string-bytes 1 4054304) (vectors 16 40431) (vector-slots 8 802992 291932) (floats 8 332 1307) (intervals 56 4741 8246) (buffers 992 17) (heap 1024 62832 40993))