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

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: coreutils; Reported by: Nicolas Boichat <nicolas@HIDDEN>; Done: Pádraig Brady <P@HIDDEN>; Maintainer for coreutils is bug-coreutils@HIDDEN.

Message received at 77535-done <at> debbugs.gnu.org:


Received: (at 77535-done) by debbugs.gnu.org; 4 Apr 2025 19:28:07 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Apr 04 15:28:07 2025
Received: from localhost ([127.0.0.1]:40189 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1u0mhy-0007y6-M1
	for submit <at> debbugs.gnu.org; Fri, 04 Apr 2025 15:28:06 -0400
Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:57760)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <pixelbeat@HIDDEN>)
 id 1u0mhv-0007xU-7i
 for 77535-done <at> debbugs.gnu.org; Fri, 04 Apr 2025 15:28:03 -0400
Received: by mail-wr1-x430.google.com with SMTP id
 ffacd0b85a97d-39ac9aea656so2138200f8f.3
 for <77535-done <at> debbugs.gnu.org>; Fri, 04 Apr 2025 12:28:03 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1743794877; x=1744399677; darn=debbugs.gnu.org;
 h=content-transfer-encoding:in-reply-to:from:content-language
 :references:to:subject:user-agent:mime-version:date:message-id
 :sender:from:to:cc:subject:date:message-id:reply-to;
 bh=TcrGkF78pGioQb/5ZONU/YBobvsqcKnubgUjMn6Rl34=;
 b=lAv880KTy3tJuCM8JdaEGqyQPDpdb0gTMkGB5pWTVK26xV39tfaq9muA5B1A99N92V
 wUNGUt5jvSiCWRqhDCIQgEZwNkCdT63UGPbip8f3C+c7dfqlqJRwoEIv9ord0sGup4Re
 2AQ29xChaaHnhSC4SBkizN+vyYD+kO0fTMUx6zYj2tXaGSTQi+XbpXWmhdeiCu4AF0ES
 NQvkI0CmP3MS9O8n4etLpzWGExwK7KGC7PWsJbBo/EUXe5273ZHDNSpQwuC2jHLVOqos
 J0tlPAJJykTMyqd8XRmarP46gh3+Jm44yVQfd4/xIRWAWa2fTa6OxOuHj+nKrDTQf8mS
 sgVw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1743794877; x=1744399677;
 h=content-transfer-encoding:in-reply-to:from:content-language
 :references:to:subject:user-agent:mime-version:date:message-id
 :sender:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=TcrGkF78pGioQb/5ZONU/YBobvsqcKnubgUjMn6Rl34=;
 b=hyJy8g+fNzXp1hoGPB9Qs+sFCNT3TUNSghkoqrmTM3hJkdrfBeLwsBBhprihFSKq9C
 KnuJcYJc8BSMfMVPFN76C8uAV32BZKCySNnvJTYVIDmqbAzhtfuvnlTt30biS9cIKMQd
 ByjrmfBf6v2EgPz8YJDkLVI90LVGgY4YLirJyK69mm6KAoOpzQ20reawPMHnRWgDRkv1
 9XdVzqKdaRIv1S+lGvw/skbyJuugl/WV3aCQNse/Gi4PdZ40zTnUs3wjXUJNexQvqcUT
 w+kHVaX0XUQAuvXGEbmlFWE8yLnrwxf4mfDV7qaW34bedxGI5n3++arP9l3iC5itL4bh
 dP7Q==
X-Forwarded-Encrypted: i=1;
 AJvYcCWqlBW6Bhspt/2OuuPNjOxJ1qZjSTEuzD8SMMjEQix9MVeEcaqo8XFKynxR7PYQGIc0tzem7KNr+Ni1 <at> debbugs.gnu.org
X-Gm-Message-State: AOJu0Yz/x/g1b0bQSKamq/eQGCuqv4FL8BKt+91dlNvhOh45IwQEz+w6
 jOn5d8qmdjvZDoDsppO5H2RgsrIWWBlhsiFzKcuLWwGoyEtb8muDAELJ/9eA6rw=
X-Gm-Gg: ASbGnctY8JO/Arlrg9LCQVgBjPcBoIfivX9HT7Ak+wFToo/wreMa/vdvUAkggIWJSlU
 FYoNlPFHCPgp15W/hA4V2dbdCZ6dCz8k9DkPMGLL6nPLc8qf85ivM9iy6LbQUyMBAdteDoIHJCg
 vHOoNkafZUgTnqg0YO5BdtvRQRKcRDjIOZmPti1/1BaDsgv+e8agSjTqyc45I2vPbGMp3VPHYHv
 gtg1qpmMw+9GX/j4BhOrjmZUF9WZguLyYvv0/Kgco3ir7TBT40zJd4sdgsFZ51a5xtxQq45pFJ7
 LGL9pZhnw1XJMdg28Uo1PInJBARwThq3DWHWyR+b/lkqSK2pC1AV8nFf/PL60CpMybgcaBRPEI3
 SjXm+EbZtH0ZZ5sA50yBwcRmaCL7TQCluMf8=
X-Google-Smtp-Source: AGHT+IF0BG7n4Noss0G+N5uZzrF7tR7/gEOMd+7yf62lmD80EnH0RGf2Ib4/b+LTpGR9kf/K9J2xig==
X-Received: by 2002:a5d:588f:0:b0:39c:1efd:ed8f with SMTP id
 ffacd0b85a97d-39d14662e4dmr3134696f8f.50.1743794876599; 
 Fri, 04 Apr 2025 12:27:56 -0700 (PDT)
Received: from [192.168.1.31]
 (86-44-211-146-dynamic.agg2.lod.rsl-rtd.eircom.net. [86.44.211.146])
 by smtp.googlemail.com with ESMTPSA id
 ffacd0b85a97d-39c301b7933sm5239401f8f.54.2025.04.04.12.27.55
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Fri, 04 Apr 2025 12:27:56 -0700 (PDT)
Message-ID: <a1cfeefb-ca6d-42a5-8701-8e8c0d607b87@HIDDEN>
Date: Fri, 4 Apr 2025 20:27:55 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird Beta
Subject: Re: bug#77535: timeout treats very short durations as `0`
To: Nicolas Boichat <nicolas@HIDDEN>, 77535-done <at> debbugs.gnu.org
References: <CAM6NUi5isNtqv5-UqtA4yMBTZcs1+sMLJ6uQvKn7QpE7pSS0dg@HIDDEN>
Content-Language: en-US
From: =?UTF-8?Q?P=C3=A1draig_Brady?= <P@HIDDEN>
In-Reply-To: <CAM6NUi5isNtqv5-UqtA4yMBTZcs1+sMLJ6uQvKn7QpE7pSS0dg@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 77535-done
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On 04/04/2025 16:26, Nicolas Boichat wrote:
> Hi,
> 
> Version: timeout (GNU coreutils) 9.6, Archlinux, x86-64.
> 
> While playing with different duration parameters to `timeout`, I
> noticed that extremely short durations, like `1e-3000`, are rounded
> down to `0`. The problem is that `0` has a special meaning (disabling
> the timeout), so I don't think this is desired.
> 
> All of these commands exit immediately:
> ```
> timeout 0.0001 cat
> timeout 1e-100 cat
> timeout 1e-300 cat
> timeout 1e-323 cat
> ```
> 
> But these never exits:
> ```
> timeout 1e-324 cat
> timeout 1e-3000 cat
> ```
> 
> As if we had typed:
> ```
> timeout 0 cat
> ```
> 
> I think there is some logic in `printf` to handle float parsing
> underflow, so maybe this can be reused in `timeout` as well.

The following should avoid this issue.

Marking this as done.

thanks!
Pádraig

diff --git a/src/timeout.c b/src/timeout.c
index 578d71070..6756cd888 100644
--- a/src/timeout.c
+++ b/src/timeout.c
@@ -371,6 +371,10 @@ parse_duration (char const *str)
        usage (EXIT_CANCELED);
      }

+  /* Clamp underflow to 1ns, as 0 disables the timeout.  */
+  if (duration == 0 && errno == ERANGE)
+    duration = 1e-9;
+
    return duration;
  }





Notification sent to Nicolas Boichat <nicolas@HIDDEN>:
bug acknowledged by developer. Full text available.
Reply sent to Pádraig Brady <P@HIDDEN>:
You have taken responsibility. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 4 Apr 2025 16:12:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Apr 04 12:12:15 2025
Received: from localhost ([127.0.0.1]:39665 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1u0jeR-0008HO-7l
	for submit <at> debbugs.gnu.org; Fri, 04 Apr 2025 12:12:15 -0400
Received: from lists.gnu.org ([2001:470:142::17]:43010)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <nicolas.boichat@HIDDEN>)
 id 1u0ix5-00067z-5d
 for submit <at> debbugs.gnu.org; Fri, 04 Apr 2025 11:27:27 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <nicolas.boichat@HIDDEN>)
 id 1u0iwq-00066D-QB
 for bug-coreutils@HIDDEN; Fri, 04 Apr 2025 11:27:13 -0400
Received: from mail-io1-f42.google.com ([209.85.166.42])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <nicolas.boichat@HIDDEN>)
 id 1u0iwp-0005If-6M
 for bug-coreutils@HIDDEN; Fri, 04 Apr 2025 11:27:12 -0400
Received: by mail-io1-f42.google.com with SMTP id
 ca18e2360f4ac-85b4277d03fso81705639f.1
 for <bug-coreutils@HIDDEN>; Fri, 04 Apr 2025 08:27:10 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1743780429; x=1744385229;
 h=to:subject:message-id:date:from:mime-version:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=kMIAk8BIWY1vriXK6/7sVpHCFuZdumn0ziOYcRZh5wg=;
 b=VdViJk6eKzdjmOQ8e2RixVPrUpjeP1stzk1v5k5kMBsebRqmSuchiR/ZSyuD08INEV
 nuDTHkcvq3by7YyDDyIwRmEMCjcC6QZLllOIXTpek7rjmtWwAlbOSigq3x6k0YcsYDgT
 VAl8B+/vf2Yoz6DjyaWrERe1m++SEkVFrvZtm1Tq7obrcoyNLy+jVEhXptLHJLssiYk0
 hdTiK7tIZ21sm7PlLcdtKrjVZQCVNClCOC56/nf2rgUOQ7N3fYS9kAhjhLjWHl4qL2PX
 3aTkeYwqVxripHaCQ3QWXHKvn+JDNGS2IQa1YRkA/LCG8K6l3PgLpHGhV5T0VbCYIUyU
 j8Eg==
X-Gm-Message-State: AOJu0YzjncONw5Pbrpb20Wc+4IyqN5F7PvcFIKRQo6cnH6hDYa22O1I7
 LLxKPtLJJlpccwHocFdemXx/fVS7RiaRKkEhmC8FCNbwUEPsWFiQBNwnrkD2pnWjD7HY0OXRkCg
 EW+4y3DL+q8I+z7/owBJptltl53luvBPPjEY=
X-Gm-Gg: ASbGncve+HU+XwWkLd94E876hDbcisZQCiCwwPVLJwTK8SNZEWrKuv1tYWPsOTeVwLu
 6GKSpEVZpxPEDh/e5sptbCD9s1Qy0oOz2pIMAOLxRzEO5uYUrdU8n15vqHm/5/Hm8GNf7V49Hbv
 fjpD4T1eGEt6OrjvGJEWVbf+Zgy43vAzqf34E=
X-Google-Smtp-Source: AGHT+IGCEUgbNbaSUg+ijpRv0pQg+j6Ypa7RBrPPFwIyvyF/PLYYCodJs3relLklUxHYbQNZoOGaa3OipvrDASwceBg=
X-Received: by 2002:a05:6e02:3701:b0:3ce:4b12:fa17 with SMTP id
 e9e14a558f8ab-3d6e3f7f812mr45735545ab.19.1743780428844; Fri, 04 Apr 2025
 08:27:08 -0700 (PDT)
MIME-Version: 1.0
From: Nicolas Boichat <nicolas@HIDDEN>
Date: Fri, 4 Apr 2025 17:26:56 +0200
X-Gm-Features: ATxdqUEoSIp3-7q8UzAhlw1H5z2kM9CSaO2hZ_WSwYIA0wWPqIMo8N1xHgLhNZ8
Message-ID: <CAM6NUi5isNtqv5-UqtA4yMBTZcs1+sMLJ6uQvKn7QpE7pSS0dg@HIDDEN>
Subject: timeout treats very short durations as `0`
To: bug-coreutils@HIDDEN
Content-Type: text/plain; charset="UTF-8"
Received-SPF: pass client-ip=209.85.166.42;
 envelope-from=nicolas.boichat@HIDDEN; helo=mail-io1-f42.google.com
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9,
 FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001,
 HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_NONE=-0.0001,
 RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001,
 RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Fri, 04 Apr 2025 12:12:13 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

Hi,

Version: timeout (GNU coreutils) 9.6, Archlinux, x86-64.

While playing with different duration parameters to `timeout`, I
noticed that extremely short durations, like `1e-3000`, are rounded
down to `0`. The problem is that `0` has a special meaning (disabling
the timeout), so I don't think this is desired.

All of these commands exit immediately:
```
timeout 0.0001 cat
timeout 1e-100 cat
timeout 1e-300 cat
timeout 1e-323 cat
```

But these never exits:
```
timeout 1e-324 cat
timeout 1e-3000 cat
```

As if we had typed:
```
timeout 0 cat
```

I think there is some logic in `printf` to handle float parsing
underflow, so maybe this can be reused in `timeout` as well.

Thanks,




Acknowledgement sent to Nicolas Boichat <nicolas@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-coreutils@HIDDEN. Full text available.
Report forwarded to bug-coreutils@HIDDEN:
bug#77535; Package coreutils. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 4 Apr 2025 19:30:02 UTC

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