From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: debugging post command hook max-lisp-eval-depth Date: Sun, 17 Jun 2018 15:16:39 -0400 Message-ID: References: <87efh5uxkl.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1529262918 15378 195.159.176.226 (17 Jun 2018 19:15:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 17 Jun 2018 19:15:18 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jun 17 21:15:14 2018 Return-path: Envelope-to: geh-help-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 1fUd8r-0003ua-Pc for geh-help-gnu-emacs@m.gmane.org; Sun, 17 Jun 2018 21:15:13 +0200 Original-Received: from localhost ([::1]:56174 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUdAy-0006To-UD for geh-help-gnu-emacs@m.gmane.org; Sun, 17 Jun 2018 15:17:24 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40662) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUdAU-0006Tj-CE for help-gnu-emacs@gnu.org; Sun, 17 Jun 2018 15:16:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUdAQ-0000Fa-CH for help-gnu-emacs@gnu.org; Sun, 17 Jun 2018 15:16:54 -0400 Original-Received: from [195.159.176.226] (port=42774 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUdAQ-0000Dq-4q for help-gnu-emacs@gnu.org; Sun, 17 Jun 2018 15:16:50 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1fUd8F-0003Ed-K6 for help-gnu-emacs@gnu.org; Sun, 17 Jun 2018 21:14:35 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 24 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:x+CiGRTUXZ1mXy3q/5Dlk5F5qkg= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:117190 Archived-At: > every now and then my Emacs will get in a bad state because of some > infinite recursion in the post-command-hook. I am reaching out for ideas > on how to debug Emacs when it gets into this weird state. Keep in mind > that it is hard to do anything with Emacs at that point since any > command (switching buffer, starting debugger) will fail with the same > error `Lisp nesting exceeds...'. Hmm... post-command-hook is run via `safe_run_hooks` which is supposed to try and catch errors such that when an error is caught the corresponding function is removed from post-command-hook. Of course, this is a just a mitigating factor, but it should prevent the problem you describe, except in those cases where the offending function is constantly re-added (e.g. by a pre-command-hook). Another approach is something like: (advice-add 'debug :around (lambda (&rest args) (let ((post-command-hook nil)) (apply args)))) -- Stefan