[From nobody Sat Sep 26 21:25:06 2026
Received: (at submit) by bugs.debian.org; 1 Aug 2026 00:06:15 +0000
X-Spam-Checker-Version: SpamAssassin 4.0.1-bugs.debian.org_2005_01_02
 (2024-03-25) on buxtehude.debian.org
X-Spam-Level: 
X-Spam-Status: No, score=-15.1 required=4.0 tests=BAYES_00,
 BODY_INCLUDES_PACKAGE,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,
 DKIM_VALID_EF,FOURLA,HAS_PACKAGE,SPF_HELO_NONE,SPF_NONE autolearn=ham
 autolearn_force=no version=4.0.1-bugs.debian.org_2005_01_02
X-Spam-Bayes: score:0.0000 Tokens: new, 27; hammy, 149; neutral, 97; spammy,
 1. spammytokens:0.987-1--H*r:53933
 hammytokens:0.000-+--H*UA:sk:x86_64-, 0.000-+--H*x:sk:x86_64-,
 0.000-+--H*RU:sk:chiark., 0.000-+--H*r:sk:chiark.,
 0.000-+--Hx-spam-relays-external:sk:chiark.
Return-path: &lt;ijackson@chiark.greenend.org.uk&gt;
Received: from permutation-city.chiark.greenend.org.uk
 ([2a00:1098:86:130::194]:53933 helo=chiark.greenend.org.uk)
 by buxtehude.debian.org with esmtps
 (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256)
 (Exim 4.96) (envelope-from &lt;ijackson@chiark.greenend.org.uk&gt;)
 id 1wpxF0-003tUX-1l for submit@bugs.debian.org;
 Sat, 01 Aug 2026 00:06:15 +0000
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
 d=chiark.greenend.org.uk; s=c.chiark; h=DKIM-Signature-Warning:Subject:To:
 Date:Message-ID:Content-Transfer-Encoding:Content-Type:MIME-Version:From:
 Sender:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From:
 Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:
 List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:
 List-Archive; bh=a1/JSyFbQwEbp6kqVB1tfBGOHUQfavzP8b3vy3MlhfU=; b=HSf7Nrdmrdew
 wSBbUQiDYPSHM/+1IQxFaPL9fygKmAPj8pV8C+0weOAQf6u+gYuObBjjLrM/EeKU/xPbheK+gx5i/
 UrPO5LeNRtn7R8viyAdcIqg8K4He+f6FhADQUCO+NywXt+9OHJ/br83b9d9qTa7qTYZJbQCtTPdFo
 W15JDldvb3ynhMJ6OIdhFFdH/jKhlQ1/DeJCyLqobv8Bq9e75QY10dRajwso49mGmJfNK1UFzMAne
 qsBrP1IEc4OrTFFCy4WYLa+HSElwsoDgbsu+WapDaVLgPAXdTFhu/lFeRsq9y3uTTiL/Ck0zex+Os
 8jQCVkflZ863nVxLx3Mocw==;
Received: by chiark.greenend.org.uk (Debian Exim 4.94.2 #2) with local
 (return-path ijackson@chiark.greenend.org.uk) id 1wpxEx-0000yV-8t
 for submit@bugs.debian.org; Sat, 01 Aug 2026 01:06:11 +0100
From: Ian Jackson &lt;ijackson@chiark.greenend.org.uk&gt;
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: &lt;27245.14451.230317.471369@chiark.greenend.org.uk&gt;
Date: Sat, 1 Aug 2026 01:06:11 +0100
To: submit@bugs.debian.org
Subject: sysread calls should check for EINTR
X-Mailer: VM 8.2.0b under 27.1 (x86_64-pc-linux-gnu)
DKIM-Signature-Warning: NOTE REGARDING DKIM KEY COMPROMISE
 https://www.chiark.greenend.org.uk/dkim-rotate/README.txt
 https://www.chiark.greenend.org.uk/dkim-rotate/f1/f1ba274c9ac5b7b415b7d8db8b7c29d5.pem
Delivered-To: submit@bugs.debian.org

Package: libhttp-server-simple-perl
Version: 0.52-2

Here's some of the code in Simple.pm:

    while ( sysread( STDIN, my $buff, 1 ) ) {
        last if $buff eq &quot;\n&quot;;
        $chunk .= $buff;
    }

Suppose a signal arrives while this is executing, but doesn't cause
perl to exit or anything.  Perl's signal handling machinery doesn't
set SA_RESTART nowadays.  read(2) will return -1 setting errno to
EINTR.  And then this will fail.

(Normal perl IO operations, so not sysread and syswrite, have the
:perlio layer which does retrying on EINTR, so are fine.)

IMO HTTP::Server::Simple ought to handle EINTR from sysread (returns
undef, sets $!) by restarting teh call.


Background:

I think this is the cause of a flaky test case
  https://salsa.debian.org/dgit-team/dgit/-/work_items/34

It fails very rarely.  The script uses HTTP::Server::Simple::Static
and has a periodic SIGALRM liveness check, so there is indeed some
slight risk of a signal arriving at just the wrong moment.

The full script is here
  https://salsa.debian.org/dgit-team/dgit/-/blob/main/tests/http-static-server#L46


I could try to prepare a patch, if you like.

Thanks,
Ian.

-- 
Ian Jackson &lt;ijackson@chiark.greenend.org.uk&gt;   These opinions are my own.  

Pronouns: they/he.  If I emailed you from @fyvzl.net or @evade.org.uk,
that is a private address which bypasses my fierce spamfilter.
]