From unknown Sat Jun 14 03:52:00 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#63858 <63858@debbugs.gnu.org> To: bug#63858 <63858@debbugs.gnu.org> Subject: Status: GNU "shuf" on Linux calls getrandom without GRND_NONBLOCK, hangs indefinitely (9.x regression) Reply-To: bug#63858 <63858@debbugs.gnu.org> Date: Sat, 14 Jun 2025 10:52:00 +0000 retitle 63858 GNU "shuf" on Linux calls getrandom without GRND_NONBLOCK, ha= ngs indefinitely (9.x regression) reassign 63858 coreutils submitter 63858 Nick Bowler severity 63858 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 02 15:25:20 2023 Received: (at submit) by debbugs.gnu.org; 2 Jun 2023 19:25:20 +0000 Received: from localhost ([127.0.0.1]:40897 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5AOm-0002Uv-I3 for submit@debbugs.gnu.org; Fri, 02 Jun 2023 15:25:20 -0400 Received: from lists.gnu.org ([209.51.188.17]:41358) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5AOh-0002Uj-1o for submit@debbugs.gnu.org; Fri, 02 Jun 2023 15:25:19 -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 ) id 1q5AOg-0004SP-Po for bug-coreutils@gnu.org; Fri, 02 Jun 2023 15:25:14 -0400 Received: from mail-pj1-x1043.google.com ([2607:f8b0:4864:20::1043]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q5AOd-00037P-55 for bug-coreutils@gnu.org; Fri, 02 Jun 2023 15:25:13 -0400 Received: by mail-pj1-x1043.google.com with SMTP id 98e67ed59e1d1-2563a4b6285so1274205a91.2 for ; Fri, 02 Jun 2023 12:25:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=draconx-ca.20221208.gappssmtp.com; s=20221208; t=1685733909; x=1688325909; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=crPsibRXuM1FCAs2lQTuxP4PHaHlSRTRgtCPfiR/6I0=; b=xeoB4+BFlC9FF7cEFWR+ndzvFZoH81GBylCOr6AHtuc+T2UHgOVNqBhDnLYBhUqjRs venhh21ZZdGkTNEQjiYsf4Lv1YwH/906knVcHPgUUYVkDE+9jp1dgGct2j3UWnAvVWEk 6ZIMmqQ15jPKBnk89MmW0SpFQSTOLjf52c1Rv/82vl1V15a5w7gQdCh7UDW7+DdOQSNM SD8OTPRmqyRkhHG/KN7Of9T+pThHDHJpIxDYI7evgRKKLQbefiEwDQXDAk8HwjFlIpCY ouskUlkroCU2SlNHDeQOUu81eSUfbP43R03NC1lzfOUNjs217UYFlcCB2NF3pJ33wn0a WUwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685733909; x=1688325909; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=crPsibRXuM1FCAs2lQTuxP4PHaHlSRTRgtCPfiR/6I0=; b=DCPjPvEI5vfLibOw2P80hw5YnaY6g5q5bD7fGwWuB8L2J6leBw4AcWPvmji0oDakzv rybs9oQU74pI5ar9YXjVqmeriYdk89+pvwgMyElWmZZVO1uS7zkwptUUtFi9eo6h0i+q YauCF8PGnyLXIAwZmE6wdbGxLxVSExqisnmOTGHWv0Fv0gBIeszv/rA73bJl8Hy1aWCR 5yDFYI4voXeGqtiL472hYUUIux8nZJOc5sEOUfk0eP99meBPZMfvOyFGC2GcYACqs9iv KX5+4+4Vzk0NE52R0ks1qQGFeltFR4uUq6luUVn00E0AQjsjE19nzAl5X5g2AuEA4uLO G9Eg== X-Gm-Message-State: AC+VfDxVVO0ocY8h/X23VuHIltyUuSXPWnB3PRGX5FZJsPHKE0nvMVWJ CRn5R+cNEMlgDUTjHM2gKfeZjq/Hau5LyFl78XXG7emGT+AI0Cx7Iw8wXq1tCiY= X-Google-Smtp-Source: ACHHUZ5Sjzd5EVBYYt12Bv5LVWg/cUbFzbFbuQIwt0Pwk4j49emFp5GxiKAl16nrF22bCpiyvxM38IFMg38YZdsQTJE= X-Received: by 2002:a17:90a:1904:b0:23a:ad68:25a7 with SMTP id 4-20020a17090a190400b0023aad6825a7mr740501pjg.2.1685733908711; Fri, 02 Jun 2023 12:25:08 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a05:6a06:1e20:b0:5b5:2ae6:3385 with HTTP; Fri, 2 Jun 2023 12:25:07 -0700 (PDT) X-Originating-IP: [162.243.96.244] From: Nick Bowler Date: Fri, 2 Jun 2023 15:25:07 -0400 Message-ID: Subject: GNU "shuf" on Linux calls getrandom without GRND_NONBLOCK, hangs indefinitely (9.x regression) To: bug-coreutils@gnu.org Content-Type: text/plain; charset="UTF-8" Received-SPF: none client-ip=2607:f8b0:4864:20::1043; envelope-from=nbowler@draconx.ca; helo=mail-pj1-x1043.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, I installed a new version of GNU coreutils (9.3), and now "shuf" appears to be blocking on Linux's cryptographic RNG init. On this particular machine, there is not a lot of entropy sources so Linux's RNG init takes an unbounded and potentially very long time. I hope nobody expects "shuf" to provide cryptographically-secure randomness (I certainly don't), and it would be nice for shuf to not hang indefinitely. Running with strace I see shuf makes two calls to getrandom, the first passes the GRND_NONBLOCK flag, and shuf appears to fall back to using clock_gettime in this case, but the second call passes 0 for flags which means "block until RNG init", and this is the one that hangs. shuf only makes the second getrandom call if there is actually input (so shuf &1 | grep getrandom % getrandom("\xd5\x55\xc9\x73", 4, GRND_NONBLOCK) = 4 % getrandom("\x76", 1, 0) = 1 note the 0 flags in the second call. When it is not working (before RNG init), the second call hangs indefinitely (killed by a signal in this case): % echo x | strace ./shuf 2>&1 [...] getrandom(0xb6f148c8, 4, GRND_NONBLOCK) = -1 EAGAIN (Resource temporarily unavailable) clock_gettime64(CLOCK_MONOTONIC, 0xbed4e810) = -1 ENOSYS (Function not implemented) clock_gettime(CLOCK_MONOTONIC, {tv_sec=270, tv_nsec=854650394}) = 0 [...] getrandom(0x1c40228, 1, 0) = ? ERESTARTSYS (To be restarted if SA_RESTART is set) --- SIGINT {si_signo=SIGINT, si_code=SI_KERNEL} --- +++ killed by SIGINT +++ I do not have this problem with coreutils 8.28. Using the GNU-specific --random-source=/dev/urandom option is a possible workaround (since /dev/urandom reads do not block). Let me know if you need any more info. Thanks, Nick