GNU bug report logs - #77535
timeout treats very short durations as `0`

Previous Next

Package: coreutils;

Reported by: Nicolas Boichat <nicolas <at> boichat.ch>

Date: Fri, 4 Apr 2025 16:13:02 UTC

Severity: normal

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: 77535 <at> debbugs.gnu.org
Cc: nicolas <at> boichat.ch, P <at> draigBrady.com
Subject: bug#77535: timeout treats very short durations as `0`
Date: Sat, 5 Apr 2025 01:03:48 -0700
[Message part 1 (text/plain, inline)]
On 2025-04-04 12:27, Pádraig Brady wrote:
> +  /* Clamp underflow to 1ns, as 0 disables the timeout.  */
> +  if (duration == 0 && errno == ERANGE)
> +    duration = 1e-9;

That isn't exactly right as the 1e-9 double-rounds to 2e-9 when we 
compute the struct timespec. Also, even with the patch the code 
mishandles 16777216.000000001 (2**24 + 10**-9) by treating it as if it 
were just 16777216. These are tiny bugs, I know, but I took up the 
challenge of doing this things more correctly by installing the attached.
[0001-timeout-round-timeouts-up.patch (text/x-patch, attachment)]

This bug report was last modified 42 days ago.

Previous Next


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