From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andy Moreton Newsgroups: gmane.emacs.bugs Subject: bug#60996: 29.0.60; Native compile fails to remove temp file for trampoline Date: Tue, 24 Jan 2023 01:18:01 +0000 Message-ID: <86edrku3w6.fsf@gmail.com> References: <74d13c46-5b26-9dd8-45dc-32b7fda25421@gmail.com> <833583ks9t.fsf@gnu.org> <86wn5evv70.fsf@gmail.com> <83r0vli9gr.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9355"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: 60996@debbugs.gnu.org Cancel-Lock: sha1:JSFNhySjQisoK20BGsU7S+06VSc= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 24 02:19:27 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 1pK7yB-0002It-BO for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 24 Jan 2023 02:19:27 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pK7xo-0007gG-0E; Mon, 23 Jan 2023 20:19:04 -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 1pK7xn-0007ft-0a for bug-gnu-emacs@gnu.org; Mon, 23 Jan 2023 20:19:03 -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 1pK7xm-0004pq-Jf for bug-gnu-emacs@gnu.org; Mon, 23 Jan 2023 20:19:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pK7xm-00086K-87 for bug-gnu-emacs@gnu.org; Mon, 23 Jan 2023 20:19:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <74d13c46-5b26-9dd8-45dc-32b7fda25421@gmail.com> Resent-From: Andy Moreton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 24 Jan 2023 01:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60996 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.167452309531087 (code B ref -1); Tue, 24 Jan 2023 01:19:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 24 Jan 2023 01:18:15 +0000 Original-Received: from localhost ([127.0.0.1]:55621 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pK7x1-00085L-9x for submit@debbugs.gnu.org; Mon, 23 Jan 2023 20:18:15 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:39628) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pK7wz-00085D-Qr for submit@debbugs.gnu.org; Mon, 23 Jan 2023 20:18:14 -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 1pK7wz-0007bz-Kh for bug-gnu-emacs@gnu.org; Mon, 23 Jan 2023 20:18:13 -0500 Original-Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pK7wy-0004m9-0X for bug-gnu-emacs@gnu.org; Mon, 23 Jan 2023 20:18:13 -0500 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1pK7wt-0000Vv-Pz for bug-gnu-emacs@gnu.org; Tue, 24 Jan 2023 02:18:07 +0100 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=geb-bug-gnu-emacs@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FREEMAIL_FORGED_FROMDOMAIN=0.149, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.248, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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:254034 Archived-At: On Mon 23 Jan 2023, Eli Zaretskii wrote: >> From: Andy Moreton >> Date: Mon, 23 Jan 2023 02:30:43 +0000 >> >> >From more expermenting with a debug build in gdb, it seem to be related >> to this code in native-elisp-load: >> >> /* If in this session there was ever a file loaded with this >> name, rename it before loading, to make sure we always get a >> new handle! */ >> Lisp_Object tmp_filename = >> Fmake_temp_file_internal (filename, Qnil, build_string (".eln.tmp"), >> Qnil); >> if (NILP (Ffile_writable_p (tmp_filename))) >> comp_u->handle = dynlib_open_for_eln (SSDATA (encoded_filename)); >> else >> { >> Frename_file (filename, tmp_filename, Qt); >> comp_u->handle = dynlib_open_for_eln (SSDATA (ENCODE_FILE (tmp_filename))); >> Frename_file (tmp_filename, filename, Qnil); >> } >> >> The renaming results in the ".eln.tmp" suffixed name having an open >> handle. That handle is still open when other code tries to delete >> the renamed ".eln" file, which fails. > > The question is: why is that .eln.tmp file still open when we are > trying to delete it? I hoped we'd be able to establish that, so that > we could decide what to do about it. But I don't yet see the > information which would explain why the file is still open. The file handle is returned from dynlib_open_for_eln (which came from a LoadLibrary call in dylib_open). More below. > Do these *.eln.tmp file remain in %TEMP% after Emacs startup? If they > remain there, then what happens if you exit Emacs and restart it? do > these files remain there or are they deleted? IOW, if we just ignore > these errors (e.g., by ignore-error), would the problem be fixed, or > will there be left-overs? The ".eln.tmp" suffixed files are only renamed temporarily, and the files only fleetingly have that name. The ".eln" suffixed file names persist after the failed delete, so will accumulate unless removed manually. >> The attached .csv file shows filesystem activity captured by Process >> Monitor for the relevant "...\comp-lambda-*" temp files during emacs >> startup. (It may be easier to read if imported into a spreadsheet). > > Maybe I don't understand how to read this, but I cannot find any > traces for the failed deletion of a .eln.tmp file. The only failure > to delete is this: > >> "14:15:24.8773402","emacs.exe","6452","SetDispositionInformationEx","C:\Users\ajm\AppData\Local\Temp\comp-lambda-SGvFx7.eln","CANNOT >> DELETE","Flags: FILE_DISPOSITION_DELETE, FILE_DISPOSITION_POSIX_SEMANTICS, >> FILE_DISPOSITION_FORCE_IMAGE_SECTION_CHECK" That line is the failed delete-file (for "comp-lambda-SGvFx7.eln") at the end of comp--native-compile. >From the Microsoft kernel docs at: https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntddk/ns-ntddk-_file_disposition_information_ex "A return value of STATUS_CANNOT_DELETE indicates that either the file is read-only, or there is an existing mapped view to the file." The earlier lines in the trace with CreateFileMapping and Load Image for "comp-lambda-SGvFx7.eln" to suggest that existing mapping created from dynlib_open (by LoadLibrary) may be the problem. >> Any idea when those changes were committed, and which changesets ? IT >> doesn't apper obvios from the commit history. > > See commit 1a8015b837. Maybe also commit 5fec9182db. Thanks for the additional details. AndyM