From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#68799: 30.0.50; emacs --fg-daemon fails silently if server-start fails Date: Tue, 13 Feb 2024 14:35:35 +0200 Message-ID: <865xysr17s.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17082"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 68799@debbugs.gnu.org, monnier@iro.umontreal.ca, jasonr@gnu.org To: Spencer Baugh Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Feb 13 13:41:14 2024 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 1rZs65-0004FG-Il for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 13 Feb 2024 13:41:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZs5j-00022s-2O; Tue, 13 Feb 2024 07:40:51 -0500 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 1rZs5c-00022I-Oa for bug-gnu-emacs@gnu.org; Tue, 13 Feb 2024 07:40:45 -0500 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 1rZs5c-0001Qr-GM for bug-gnu-emacs@gnu.org; Tue, 13 Feb 2024 07:40:44 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rZs5t-0004Zg-Mk for bug-gnu-emacs@gnu.org; Tue, 13 Feb 2024 07:41:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 13 Feb 2024 12:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68799 X-GNU-PR-Package: emacs Original-Received: via spool by 68799-submit@debbugs.gnu.org id=B68799.170782801617504 (code B ref 68799); Tue, 13 Feb 2024 12:41:01 +0000 Original-Received: (at 68799) by debbugs.gnu.org; 13 Feb 2024 12:40:16 +0000 Original-Received: from localhost ([127.0.0.1]:42773 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rZs59-0004YA-Ej for submit@debbugs.gnu.org; Tue, 13 Feb 2024 07:40:16 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:57752) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rZs15-0004QI-Au for 68799@debbugs.gnu.org; Tue, 13 Feb 2024 07:36:04 -0500 Original-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 1rZs0h-0000fr-Cm; Tue, 13 Feb 2024 07:35:39 -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=NUpho1mTKC7WXqXw1bSJ6XNtHR9lSp+ThjuDFi/jmgU=; b=iSdkbJ0L4T/O X2jeUP5gvtkUMxIHT4ZoJQk9uaq873rtUnFE86H2kJq1iLd7RM2RTJb74JZOMNrZi1JfXxFX3U8YR OJ0CDWUSh6utZ1VvZH+tc70xnzFGUs3f1kRHy5epv1fCyGXipt6kO71wNEMb0lOiPovs3qhZrY8vY txvONU2irzF6ycajZ+Xpos/IQ81qTS1BoVUxHsuj5kFCzcdpCPqt4mbsRFRs4ZQf147Is/hDou0fo vI3OWnJ6vLThpNBEVahNUBcp3MlW1AcDnNTcUN/rguVMlJVPclI61MbHOY7H66c8JNRb5GoP2/Lrd bzPGCRt+GIW0R8m/f18z8Q==; In-Reply-To: (message from Spencer Baugh on Mon, 12 Feb 2024 17:10:34 -0500) 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:279958 Archived-At: > Cc: Stefan Monnier , Jason Rumney > From: Spencer Baugh > Date: Mon, 12 Feb 2024 17:10:34 -0500 > > Spencer Baugh writes: > > 1. emacs -Q --fg-daemon=/nonexistent/dir/sock > > 2. Emacs prints "Starting Emacs daemon." and sits in foreground. > > 3. emacsclient -c -s /nonexistent/dir/sock > > 4. emacsclient prints and exits: > > emacsclient: can't find socket; have you started the server? > > emacsclient: To start the server in Emacs, type "M-x server-start". > > emacsclient: error accessing socket "/nonexistent/dir/sock" > > > > This is because in step 1, the server actually failed to start, but > > Emacs did not log that at all. In fact, it's impossible to access the > > Emacs started in 1 now, since it's not actually running a server and it > > has no frames. > > Okay, I found what one might call the root cause, the following code and > comment. Adding Stefan and Jason to CC as the original authors. > > /* The initial frame is a special non-displaying frame. It > will be current in daemon mode when there are no frames > to display, and in non-daemon mode before the real frame > has finished initializing. If an error is thrown in the > latter case while creating the frame, then the frame > will never be displayed, so the safest thing to do is > write to stderr and quit. In daemon mode, there are > many other potential errors that do not prevent frames > from being created, so continuing as normal is better in > that case. */ > || (!IS_DAEMON && FRAME_INITIAL_P (sf)) > > The comment is mostly sensible: we should exit while initializing, and > shouldn't exit while in the steady state of daemon mode. Bug#1310 and bug#1836 are also relevant here. > However, it doesn't handle the case when Emacs is initializing *and* in > daemon mode. In that case, an error will prevent frames from being > created, just like in non-daemon mode. > > So this check really wants to be something more like: > || ( IS_DAEMON && [something to check if Emacs is starting up]) > || (!IS_DAEMON && FRAME_INITIAL_P (sf)) > > Not sure what [something to check if Emacs is starting up] should be > though. after-init-time, I guess. But note that this still leaves a window between where that is set non-nil and starting the server. Also, the patch for server-start which prevents it from erroring out is still needed, because we do want to show the error message about being unable to start the daemon. And this solution will still print error messages that are not specific enough to be helpful. E.g., what do you do if you try starting the daemon and see wrong-type-argument, stringp, nil and that's all? And that is even before we consider the use case where stderr of the daemon is redirected to the great void, which happens in some cases. So my vote is still for diagnosing the important places where a fatal error could happen, and adding a clear diagnostic there. Yes, it is more work. But the gain will be much higher.