From: Gioele Barabucci <gioele@svario.it>
To: Florian Weimer <fweimer@redhat.com>,
Gioele Barabucci via Systemtap <systemtap@sourceware.org>
Subject: Re: [PATCH] dtrace: Use deterministic temp file creation for all temp files
Date: Mon, 27 Feb 2023 16:59:58 +0100 [thread overview]
Message-ID: <3de411c4-8cbd-667b-a64e-aeeac297ea94@svario.it> (raw)
In-Reply-To: <87fsarm7m5.fsf@oldenburg.str.redhat.com>
On 27/02/23 16:49, Florian Weimer wrote:
>> +def mktemp_determ(sources, suffix):
>> + # for reproducible-builds purposes, use a predictable tmpfile path
>> + sha = hashlib.sha256()
>> + for source in sources:
>> + sha.update(source.encode('utf-8'))
>> + fname = ".dtrace-temp." + sha.hexdigest()[:8] + suffix
>> + tries = 0
>> + while True:
>> + tries += 1
>> + if tries > 100: # if file exists due to previous crash or whatever
>> + raise Exception("cannot create temporary file \""+fname+"\"")
>> + try:
>> + wxmode = 'x' if sys.version_info > (3,0) else 'wx'
>> + fdesc = open(fname, mode=wxmode)
>> + break
>> + except FileExistsError:
>> + time.sleep(0.1) # vague estimate of elapsed time for concurrent identical gcc job
>> + pass # Try again
>> +
>> + return fdesc, fname
>
> This looks like creating a file with a suitable name may block forward
> progress indefinitely? Like from a previous crash of the tool?
Hi Florian,
yes, that's correct. This code will exit with a FileExistsError if a
temporary file from a previous run are still around.
However this is not a new behavior: this piece of code is already in
dtrace. What this patch does is using it for all intermediate tempfiles,
not just for the final temporary files.
> It might be more robust to use a dedicated temporary directory and a
> predictable file name under that directory.
Doesn't this suffer from the same issue? If dtrace finds that
predictable dir/file path it will exit (impeding a second run). Or am I
missing something?
Regards,
--
Gioele Barabucci
next prev parent reply other threads:[~2023-02-27 16:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-27 12:13 Gioele Barabucci
2023-02-27 15:49 ` Florian Weimer
2023-02-27 15:59 ` Gioele Barabucci [this message]
2023-02-27 16:47 ` Florian Weimer
2023-02-27 17:15 ` Gioele Barabucci
2023-02-27 17:34 ` Florian Weimer
2023-02-28 3:46 ` Gioele Barabucci
2023-02-28 10:12 ` Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3de411c4-8cbd-667b-a64e-aeeac297ea94@svario.it \
--to=gioele@svario.it \
--cc=fweimer@redhat.com \
--cc=systemtap@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).