From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.bugs Subject: bug#61350: Eglot over Tramp freezes with large project Date: Thu, 02 Mar 2023 12:01:32 +0100 Message-ID: <87y1ofct83.fsf@gmx.de> References: <87y1ootw2t.fsf@gmail.com> <69968923.705640.1677163650760@office.mailbox.org> <87a613f0b7.fsf@gmx.de> <87r0udvmzr.fsf@gmx.de> <878rglxrzm.fsf@gmail.com> <87cz5wmjbx.fsf@gmx.de> <87h6v8f7u9.fsf@gmail.com> <87o7pflfcd.fsf@gmx.de> <87wn43e9ht.fsf@gmail.com> <874jr6oont.fsf@gmx.de> <87sfeqd4zi.fsf@gmail.com> <877cw1swjm.fsf@gmx.de> <87k0016dgo.fsf@gmx.de> <1458446553.50372.1677606917251@office.mailbox.org> <87ilfkh89k.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36174"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Thomas Koch , 61350@debbugs.gnu.org To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Mar 02 12:02:46 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 1pXghy-0009AO-3J for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 02 Mar 2023 12:02:46 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXghV-0004t6-L1; Thu, 02 Mar 2023 06:02:17 -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 1pXghK-0004qM-MQ for bug-gnu-emacs@gnu.org; Thu, 02 Mar 2023 06:02:09 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pXghG-0007hx-8I for bug-gnu-emacs@gnu.org; Thu, 02 Mar 2023 06:02:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pXghF-0001ie-UI for bug-gnu-emacs@gnu.org; Thu, 02 Mar 2023 06:02:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 02 Mar 2023 11:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61350 X-GNU-PR-Package: emacs Original-Received: via spool by 61350-submit@debbugs.gnu.org id=B61350.16777549026582 (code B ref 61350); Thu, 02 Mar 2023 11:02:01 +0000 Original-Received: (at 61350) by debbugs.gnu.org; 2 Mar 2023 11:01:42 +0000 Original-Received: from localhost ([127.0.0.1]:55953 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pXggw-0001i6-Ci for submit@debbugs.gnu.org; Thu, 02 Mar 2023 06:01:42 -0500 Original-Received: from mout.gmx.net ([212.227.17.20]:38719) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pXggu-0001ht-Cc for 61350@debbugs.gnu.org; Thu, 02 Mar 2023 06:01:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1677754893; i=michael.albinus@gmx.de; bh=72zGc/xBgN5Mh6LYH/dAt7RpiaAhjT2UZEwRWNqJZEM=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=sEYv572YidQASa0ITkJ/jX3kYj5OuPfX8jz8XzSfWQSkfesaftVZjh6KJaDCjXhGs OYpILmqnaGtwrzSVH3+4Ivo24VZxAsBQFeqf53UvRQP67fac7ta3xpcrH0pooHBRKx fUcaPqYUokbaY2ba8KjBsJyS6hV5kAIM1PMhOHRazIZrM3wZedmtZl581lfDSkCKyF 7pYSb63bTOZ5UJR+PmQYerResfLXYXGJoeFEpUjq1JBDukwSRxhqzL2ozgpojOnbfJ E4R01Lo69Y4LSpX3fZIy+mgQauDu7r4zavSjOi3E9rhDbj/1OeN9fn60n+ThIyk/cT A//K8VnOR8Akg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from gandalf.gmx.de ([185.89.39.22]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M6Daq-1peJSn1ssq-006hp1; Thu, 02 Mar 2023 12:01:33 +0100 In-Reply-To: <87ilfkh89k.fsf@gmail.com> ("=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?="'s message of "Wed, 01 Mar 2023 14:10:47 +0000") X-Provags-ID: V03:K1:BHp+k+BCG9fGAH2u2h5x5DFY86CnXnLbLa6A26mhTvk6OwT2XAO fftkPULmfElJBTv4jL0sZZxteNABDqH9TLyhfNw3G1Yw9rawV7XVJmTfffuts9fnw+R1trt zb7FVMO5d8w/BtBqcP/poqfdkaGneVXuLMvvd3R6DvQXxert2/zJXKuoiQ4iXQ8NRJ3vbUS cwsRCde8b0LcYtTZmdGzg== UI-OutboundReport: notjunk:1;M01:P0:IJzCwUmxy/w=;YBa9gbquSFmt8y5dN2LIo7b1T3n 3LjUwt+JIQ47wI314l93aDSDyrUULopR9tVR53LL7YkSG3af8MJpIsbgMu2ezQMl15dev+lBV 7bC+MBuNb9hKWsWNdCiv/gBXJgsUjm0rvsiVyxDwOS0QX+JuDudiiJJ4hZWA3HYjn8PLM0l+I yL2TpURGFAwHP4brsXE3kHILtk+38vUTytMd0O64F2c0CxJnFDLk8ooZH1ABMiCUqGLpdhDJi Hx1kGImfwGk2QA0+EFCiOV8ryNKqncztzK/f5rNiw8hI4+G1aQRZ87dIcbn2F7oNDkE8qbRZT gBkuJv820U2Rp7gVQrT0Xj9dNHpT3y6yhAvqjBuadD+dmmbnwBdZXmoHoL/shCh596hqhr+XT dnCwFGk6yCqiuZIxLD8MgY5y/swLnPecD7nxkBpHUIlIK0tb86kyngms+89VRsJt0iJunAfG7 cesSyQAK/0XgyVR1STzxAYAW/5jWG60VUNDn4iP/LjcWOhCfq2fICnJ2IcjzFSsqipi2qQ+Xg XUXuas6T9ekC0j3mP+RkPw8cvKtsbE36eKD/XLZu5ZcDJ67G/2Xs5MHZJHq2MZyZdBeDpXIoM ZpUDtGy1Pk8uQw/rEZ+cW3LMTkgeY7KTCGLyT+qdH/ZaJxB4EL4139S/GlSzgr4ffxXK2Cmqy RssO1ltFV+gj7wCkqf6XbkMpidn0YGee7uxSvlDjGhMculI2dZRQykLC2hxAAFIM6XOcAz+bS fatGUE/tCJz1LuufHJ26sopsGvm2mlxKQ4t2VE9VrLJcCvRrAPaVR9VuqJ+j/IBADUhIeME3 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:257135 Archived-At: Jo=C3=A3o T=C3=A1vora writes: Hi Jo=C3=A3o, > But JUST-THIS-ONE _is_ relevant when there is more than one process. > Here, there is. There's one process, the jsonrpc.el process, henceforth > 'jprocess', and the Tramp process, henceforth 'tprocess'. jprocess > receives only JSONRPC data from the LSP server. It "thinks" it is > talking directly to a JSONRPC server, but in Tramp scenarios it is being > fed data from tprocess, which is the process connected to the remote > host. In tprocess, other things, such as shell interactions are going > on. > > Michael can probably confirm, correct or deny this. More or less correct. But I still can't say which process gets output when, because I cannot debug accept-process-output (it's a C function). And running Emacs under gdb changes timings, which is important I believe. > When one (accept-process-output tprocess nil nil 'JUST-THIS-ONE=3Dt) one > must be absolutely sure that tprocess is going to send _something_ > "soon". If it doesn't, we'll hang indefinitely (until the process dies > or the user quits) Yes. But Tramp calls accept-process-output only, if it has send a command to the remote shell, and it expects something to be returned. At least the shell prompt. During my tests I have also changed this to --8<---------------cut here---------------start------------->8--- (while (accept-process-output tprocess 0 nil 'JUST-THIS-ONE)) --8<---------------cut here---------------end--------------->8--- but it didn't help either. > That's what has been confirmed through a backtrace. It's a particular > accept-process-output call in tramp-wait-for-regexp that hangs, > understandibly so. Yes. > Now, 'tramp-check-for-regexp' uses a somewhat non-standard technique of > searching for messages: it searches them from the back, from the end of > the tprocess's buffer. I don't know what motivated this, but I find it > odd. I find one of its callees, tramp-search-regexp, particularly > suspicious: > > (defun tramp-search-regexp (regexp) > "Search for REGEXP backwards, starting at point-max."" > (goto-char (point-max)) > ;; We restrict ourselves to the last 256 characters. There were > ;; reports of a shell command "git ls-files -zco --exclude-standard" > ;; with 85k files involved, which has blocked Tramp forever. > (re-search-backward regexp (max (point-min) (- (point) 256)) 'noerro= r)) > > See the comment there? Only 256 characters back are inspected. Yes. But the regexp it searches for is the final shell prompt. Something like "///4b3b7d4fa561141e84c94a1cf25e8575#$", which is shorter than 256 bytes for sure. > So, finally, here's my conjecture: > > 1. Tramp goes into 'tramp-wait-for-regexp'. tprocess's buffer already > the message that 'found' is supposed to return, but it also has a lot > more stuff, say a lot of JSONRPC data from the LSP server that also > came into that tprocess buffer and is awaiting to be delivered to > jprocess. > > 2. This data is for piping into jprocess, where the JSONRPC message will > be decoded, but it will probably never arrive at its destination. > > 3. 'found' will be nil in tramp-wait-for-regexp, because of the > tramp-search-regexp limitation. > > 4. tramp-wait-for-regexp will issue the "risky" accept-process-output > call. > > 5. there is no more data that accept-process-output wants to put in the > buffer, because the LSP server is fine for the moment. > > 6. Emacs hang > > Just a conjecture. Yes, this is more or less the scenario. But I still don't understand why not all data are delivered through the socket ssh is using. Could it be there is a limitation, how much data could be buffered by ssh? >> I have a vague feeling, that Tramp could be improved with a work queue >> such that requests to tramp from notification or timer threads get >> blocked while another tramp command is still waiting for a >> reply. > > There are no (usable) threads in Emacs. There are. I made Tramp using threads, and it worked fine, when no interactive dialogue inside a thread happened. > Timers are events, and so are runs of each processe's process filter. > Those two are what creates asynchronicity and the emulation of > simultaneity in Emacs. When jprocess's filter sees a whole JSONRPC > message, it calls the message handler. Timers and process filters are the cause of the "Forbidden reentrant call in Tramp" errors. Wwe must do anything, solving this. > Jo=C3=A3o Best regards, Michael.