GNU bug report logs - #75588
[PATCH] guix: utils: Delete temporary output files.

Previous Next

Package: guix-patches;

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


Message #13 received at 75588 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Kierin Bell <fernseed <at> fernseed.me>
Cc: 75588 <at> debbugs.gnu.org, Andreas Enge <andreas <at> enge.fr>,
 Janneke Nieuwenhuizen <janneke <at> gnu.org>
Subject: Re: [bug#75588] [PATCH] guix: utils: Delete temporary output files.
Date: Thu, 16 Jan 2025 09:52:01 +0100
Hello,

Kierin Bell <fernseed <at> fernseed.me> skribis:

> 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.

[…]

> --- 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))))))

AFAICS the current code is fine because ‘template’ is modified by
‘mkstemp!’:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (define template (string-copy "/tmp/guix-example-XXXXXX"))
scheme@(guile-user)> (mkstemp! template)
$15 = #<input-output: /tmp/guix-example-uZ5z4s 13>
scheme@(guile-user)> template
$16 = "/tmp/guix-example-uZ5z4s"
--8<---------------cut here---------------end--------------->8---

All good?

Thanks,
Ludo’.




This bug report was last modified 121 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.