On Sun 22 Jan 2023, Eli Zaretskii wrote: >> Date: Sat, 21 Jan 2023 22:12:10 +0000 >> From: Andy Moreton >> >> Recently emacs 29 (and master) has started showing an error and >> backtrace during startup: >> >> Debugger entered--Lisp error: (permission-denied "Removing old name" >> "Permission denied" "c:/Users/ajm/AppData/Local/Temp/comp-lambda-MTAMbr...") >> delete-file("c:/Users/ajm/AppData/Local/Temp/comp-lambda-MTAMbr...") > > We need a reproducible recipe to investigate this, or results of such > investigation by you: which code has the file open when we try > deleting it, and why that other code has it open? > > For a recipe, it should be enough to present a minimal init file which > causes the problem (but pleased make it really minimal: as few lines > as strictly needed for reproduction) Agreed, but this appear to be tiing sensitive, so a minimised reproducer may take a while to reduce down from my init file. > Btw, "comp-lambda-MTAMbr..." seems to tell that it's some part of > comp.el, which sounds strange: comp.el is supposed to be > natively-compiled during the build, and that includes the trampolines > for it. Hmm... 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 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).