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#46972: 28.0.50; [feature/native-comp] Emacs locks itself during native compilation because of permission denied Date: Sun, 14 Mar 2021 12:51:06 +0200 Message-ID: <835z1ugg9x.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27957"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 46972@debbugs.gnu.org To: Matt M Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 14 11:52:14 2021 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 1lLOM2-0007AT-N2 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 14 Mar 2021 11:52:14 +0100 Original-Received: from localhost ([::1]:34454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lLOM1-0006Jg-Pe for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 14 Mar 2021 06:52:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lLOLr-0006JE-SD for bug-gnu-emacs@gnu.org; Sun, 14 Mar 2021 06:52:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49685) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lLOLq-00059o-KD for bug-gnu-emacs@gnu.org; Sun, 14 Mar 2021 06:52:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lLOLq-0007In-AM for bug-gnu-emacs@gnu.org; Sun, 14 Mar 2021 06:52:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 14 Mar 2021 10:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46972 X-GNU-PR-Package: emacs Original-Received: via spool by 46972-submit@debbugs.gnu.org id=B46972.161571907628003 (code B ref 46972); Sun, 14 Mar 2021 10:52:02 +0000 Original-Received: (at 46972) by debbugs.gnu.org; 14 Mar 2021 10:51:16 +0000 Original-Received: from localhost ([127.0.0.1]:32998 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lLOL5-0007Hb-Uj for submit@debbugs.gnu.org; Sun, 14 Mar 2021 06:51:16 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:54830) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lLOL3-0007HM-Ua for 46972@debbugs.gnu.org; Sun, 14 Mar 2021 06:51:14 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:50471) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lLOKu-0004bv-QA; Sun, 14 Mar 2021 06:51:05 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3942 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1lLOKp-0004a3-HN; Sun, 14 Mar 2021 06:51:01 -0400 In-Reply-To: (message from Matt M on Sat, 6 Mar 2021 17:23:34 +0000) 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" Xref: news.gmane.io gmane.emacs.bugs:202359 Archived-At: > From: Matt M > Date: Sat, 6 Mar 2021 17:23:34 +0000 > > I'm on windows using latest native compilation. I noticed that when doing > doom sync (I use Doom emacs) it would hang on the native compilation > step. I looked at the opened emacs processes in the task manager > during this bug to try to find a file with which I could make the bug > trigger again. In the task manager I see that about 10 emacs processes > are stuck on 10 files. > > Using this file: https://pastebin.com/z4wLheXa as > emacs-async-comp-ox-ascii.el, I call the following command: > > emacs -Q --batch -l c:/Users/Matt/emacs-async-comp-ox-ascii.el > > Compiling c:/Users/Matt/.emacs.d/.local/straight/build-28.0.50/org-mode/ox-ascii.el... > > It never finishes. If I interrupt the process I get the following > backtrace: > > Debugger entered--Lisp error: (file-error "Removing old name" "Permission denied" "c:/Users/Matt/.emacs.d/.local/cache/eln/28.0.50-4c...") > kill-emacs(t) > command-line() > normal-top-level() > > Removing old name: Permission denied, c:/Users/Matt/.emacs.d/.local/cache/eln/28.0.50-4c6fa13f/ox-ascii-dcca1ba0-825ea35cp6iXUJ.eln.old > Debugger entered--Lisp error: (file-error "Removing old name" "Permission denied" "c:/Users/Matt/.emacs.d/.local/cache/eln/28.0.50-4c...") > command-error-default-function((file-error "Removing old name" "Permission denied" "c:/Users/Matt/.emacs.d/.local/cache/eln/28.0.50-4c...") "" debug) > apply(command-error-default-function ((file-error "Removing old name" "Permission denied" "c:/Users/Matt/.emacs.d/.local/cache/eln/28.0.50-4c...") "" debug)) > #f(advice-wrapper :after command-error-default-function help-command-error-confusable-suggestions)((file-error "Removing old name" "Permission denied" "c:/Users/Matt/.emacs.d/.local/cache/eln/28.0.50-4c...") "" debug) > > It renamed a file from file.eln to file.eln.old, then tries to delete > the file.eln.old but gets a Permission denied error. > > If I start the same command again without interrupting, and try to > delete the file.eln.old manually, I get the error: > Can't remove file because the file is opened in emacs.exe > > And the only emacs.exe process runnin on the computer is the one doing > the native compilation, the one which created the file.eln.old. > > So that seems to indicate that the emacs process that renames the file > doesn't have the permission to remove the same file because of it being > opened in itself. I'm trying to understand what's going on in your case, and I'm quite confused. Can you help me understand what happens there? The error message quoted above come from the delete-file call. However, the only place where we call delete-file in comp-delete-or-replace-file is here: (ignore-errors (delete-file oldfile)) and that ignores any errors. So how come this still signals an error in your case? Likewise, I don't understand how replacing rename-file with delete-file fixes this problem. Moreover, I actually don't think these error messages are related to what really happens during compilation, I think they are related to the fact that you "interrupted the process" (how did you do that, btw?). Because the backtrace shows you invoked kill-emacs interactively, and that triggered the error. When Emacs exits, it attempts to clean up *.eln.old files left behind. Can you show the list of .eln.old files in the relevant directories that are left when the compilation is stuck? And also, can you try figuring out whether any of those .eln.old files are open in any of the running Emacs processes? One way of finding this out is by using the Process Explorer from SysInternals: it can show all the files that a given process has open. Andrea, it looks like the inner loop in eln_load_path_final_clean_up isn't protected against errors? IOW, if Fdelete_file signals an error, it won't be caught, is that right?