From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0EBBD3857720; Wed, 10 Jan 2024 22:01:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0EBBD3857720 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704924105; bh=qneiJFwvZaAMxTRChwkUvSFAUJ8jP3DwGm3PtnJqkIQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=y70HaDXtRb1VsYwSB9hWd0V8whcWhOVcBMQeg3P6nImvx32wuP0zMXSBjGHXCYdgo E16yGeG9AI+jEfepYVKYSMgJgLZQbKhv1dOyvF7MS+CXOK4kZal9smWM9clonUSdWh p5AGqFbpdGRDCT8doJh6as2sRY4HWunm/DcLFejw= From: "dmalcolm at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/113314] -Wanalyzer-infinite-loop false positive seen on haproxy's fd.c Date: Wed, 10 Jan 2024 22:01:44 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: analyzer X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dmalcolm at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: dmalcolm at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113314 --- Comment #1 from David Malcolm --- Indeed, if this is a single-threaded program, then this code: 63 void 64 fd_add_to_fd_list(volatile struct fdlist* list, int fd) 65 { 66 int next; 67 int new; 68 int old; 69 int last; 70 redo_next: 71 next =3D fdtab[fd].update.next; 72 if (next > -2) 73 goto done; 74 if (next =3D=3D -2) 75 goto redo_next; does look like an infinite loop when next =3D=3D 2. Perhaps the presence of the atomic builtin later in the function should be a clue to the analyzer that this is multi-threaded, and that fdtab[fd].update.next can be changed (presuambly by another thread)=