From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#65897: 29.1.50; Debugging errors surfaced through emacsclient is hard Date: Mon, 18 Sep 2023 10:00:42 -0400 Message-ID: References: <83msxols9n.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39675"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Spencer Baugh , 65897@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 18 16:03:11 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qiEqE-0009xW-1T for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 18 Sep 2023 16:03:10 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiEq0-0006LA-BU; Mon, 18 Sep 2023 10:02:56 -0400 Original-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 1qiEpy-0006Kh-Et for bug-gnu-emacs@gnu.org; Mon, 18 Sep 2023 10:02:54 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qiEpy-00039n-5T for bug-gnu-emacs@gnu.org; Mon, 18 Sep 2023 10:02:54 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qiEq6-0005kZ-0T for bug-gnu-emacs@gnu.org; Mon, 18 Sep 2023 10:03:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 18 Sep 2023 14:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65897 X-GNU-PR-Package: emacs Original-Received: via spool by 65897-submit@debbugs.gnu.org id=B65897.169504573522025 (code B ref 65897); Mon, 18 Sep 2023 14:03:01 +0000 Original-Received: (at 65897) by debbugs.gnu.org; 18 Sep 2023 14:02:15 +0000 Original-Received: from localhost ([127.0.0.1]:53941 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qiEpL-0005jA-In for submit@debbugs.gnu.org; Mon, 18 Sep 2023 10:02:15 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:27030) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qiEpI-0005ip-Ae for 65897@debbugs.gnu.org; Mon, 18 Sep 2023 10:02:14 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id AAF22806AC; Mon, 18 Sep 2023 10:01:58 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1695045717; bh=YZVPqJPVE1hQf3TJGfs84Ac6T31ocj6oCeP6FfVnQXY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=kwuPJnR1mJ4egrbhIov72Lcrz4Hm0e4pQxXhzVR0UisV5+YAbSrl8Cje9dtbGbYXy xTig/mTbA1BQ5T7F5kfgBBNh7YOtGxRqyKY2SikKFSEAl81rWYaB+kz6JiExS58Nzb eEVyQVJ1rb2Q4iY3cpan07Igbv1yuctXBFZMv8AuMsBtxJ0gQpB4mBZgzctwvMADu4 RqoWEvEH4B+e3VVnClcHVrORz2ONDo2RAy1cI8UXxpcMr5FJFtxyE5fDryFE1Rl80B VMKCfOSfuEbl2hw6a30OV5vZKNry8wA5fQnfnryPwM047MsnmYw7UjBNz5DrPyEHM5 gpMBDg9nwXwWQ== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 83D5480250; Mon, 18 Sep 2023 10:01:57 -0400 (EDT) Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 731CB1201C6; Mon, 18 Sep 2023 10:01:57 -0400 (EDT) In-Reply-To: <83msxols9n.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 14 Sep 2023 17:54:28 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:270796 Archived-At: >> Toy example: >> 1. emacs -Q >> 2. (server-start) >> 3. (add-hook 'before-make-frame-hook (lambda () (error "frame hook error"))) >> 4. emacsclient -c >> >> The output of emacsclient is: >> >> Waiting for Emacs... >> *ERROR*: frame hook error >> >> That's all, there is no way to get more information about the error that >> happened. >> >> Ideally, when emacsclient encounters an error and debug-on-error is >> non-nil, it should cause Emacs to enter the debugger. > > I'm not sure we can allow entering the debugger from server-execute. > That function is documented as being called from timers and process > filters, so entering the debugger might be unsafe. AFAIK it is perfectly safe to drop into the debugger when running timers and process-filters. I believe the reason why this doesn't happen here is because of the `condition-case` used to grab the error and send it to Emacsclient's output. See patch below. We could also offer a way to grab the backtrace and send it over to Emacsclient's output. Stefan diff --git a/lisp/server.el b/lisp/server.el index 10f15598221..2536a9c6591 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -1175,7 +1175,7 @@ server-process-filter (when prev (setq string (concat prev string)) (process-put proc 'previous-string nil))) - (condition-case err + (condition-case-unless-debug err (progn (server-add-client proc) ;; Send our pid