From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.svario.it (mail.svario.it [IPv6:2a02:2770:13::112:0:1]) by sourceware.org (Postfix) with ESMTPS id BCB1B3858D39 for ; Mon, 27 Feb 2023 16:00:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BCB1B3858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=svario.it Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=svario.it Received: from [IPV6:2a01:c23:6ca5:7800:c4d:8462:3bee:6ce2] (dynamic-2a01-0c23-6ca5-7800-0c4d-8462-3bee-6ce2.c23.pool.telefonica.de [IPv6:2a01:c23:6ca5:7800:c4d:8462:3bee:6ce2]) by mail.svario.it (Postfix) with ESMTPSA id 14C02D1F33; Mon, 27 Feb 2023 16:59:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svario.it; s=201710; t=1677513599; bh=gzspOpXXcTaQa8xe+eQrPxqXy/UO1o/zwt1EYyzrBXA=; h=Date:To:References:From:Subject:In-Reply-To:From; b=Ms6kC1s08iQ1Lise91FWYhSu80HOtUoCO0rwxZ466+5PG2jzYATdAv0uOX7hFkMV9 D6aq00qX2z5FQ6y425JWcN0e6YYHNhb3H1mg+yHWJiwep3GphUHE8E6KlutobCWZDh LXGzeoKPp98aji9bky+DGCH4VE68G9n7MJ2zqWt8n+APeO+v40C0bgoTZGX7i1zNeH llb2QErRTHfGqXEbm028X93xqqq0s6D2s9ZI1rpsuT676HyjGg5OJbLF3x04MjfbEh jfnTOHk2a8sZFYLzBJPIp96rjX8fd0lepSjeCHSCQ1GxPo7mYNMjNzusMYJiqEVuxl TJAyncCNjnjFg== Message-ID: <3de411c4-8cbd-667b-a64e-aeeac297ea94@svario.it> Date: Mon, 27 Feb 2023 16:59:58 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Content-Language: en-US To: Florian Weimer , Gioele Barabucci via Systemtap References: <6bfff40c-2c4b-c119-116d-7834310299d7@svario.it> <87fsarm7m5.fsf@oldenburg.str.redhat.com> From: Gioele Barabucci Subject: Re: [PATCH] dtrace: Use deterministic temp file creation for all temp files In-Reply-To: <87fsarm7m5.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS,TXREP,WEIRD_QUOTING autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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