GNU bug report logs -
#75588
[PATCH] guix: utils: Delete temporary output files.
Previous Next
Reported by: Kierin Bell <fernseed <at> fernseed.me>
Date: Wed, 15 Jan 2025 16:53:02 UTC
Severity: normal
Tags: patch
Done: Kierin Bell <fernseed <at> fernseed.me>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
* guix/build/utils.scm (call-with-temporary-output-file): Delete and
pass procedure the actual temporary file name, not the template name.
Change-Id: Id8e5da55444195fcee91517cf63ec8ebd20942e5
---
This change will trigger *many* rebuilds, I think because
'call-with-temporary-output-file' is used by 'download-to-store'.
This patch fixes a bug that causes: 1) the procedure passed to
'call-with-temporary-output-file' to always be called with the file name
template string "/guix-file.XXXXXX" rather than the name of the created
temporary file; and 2) the temporary file to persist rather than being
deleted.
Unless I'm missing something, Guix is creating temporary files without
deleting them and nobody is noticing.
Also, more importantly, it's a miracle that nothing has broken because
of issue #1. Apparently, in most applications in the Guix code base, the
procedures passed to this function discard their second argument (the
port) and only use the first argument (what should be the file name).
After a quick search, the only exceptions that I could find are some
unit tests and 'call-with-luks-key-file' in (gnu installer parted). I'm
not sure how this hasn't caused issues there.
I haven't had time to test this yet, because it triggers so many
rebuilds.
guix/build/utils.scm | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 94714bf397..dda8fb9d82 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -287,15 +287,16 @@ (define (call-with-temporary-output-file proc)
call."
(let* ((directory (or (getenv "TMPDIR") "/tmp"))
(template (string-append directory "/guix-file.XXXXXX"))
- (out (mkstemp! template)))
+ (out (mkstemp! template))
+ (filename (port-filename out)))
(dynamic-wind
(lambda ()
#t)
(lambda ()
- (proc template out))
+ (proc filename out))
(lambda ()
(false-if-exception (close out))
- (false-if-exception (delete-file template))))))
+ (false-if-exception (delete-file filename))))))
(define (call-with-ascii-input-file file proc)
"Open FILE as an ASCII or binary file, and pass the resulting port to
base-commit: b696658ee8e0655b17f5d26e024956b5148e36d6
--
2.47.1
This bug report was last modified 122 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.