[Bug 295101] LLVM crash in 16-CURRENT

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 29 May 2026 23:05:28 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=295101

--- Comment #3 from commit-hook@FreeBSD.org ---
A commit in branch stable/14 references this bug:

URL:
https://cgit.FreeBSD.org/src/commit/?id=fc1ab22fb3b86093be00c010a57feb1fefceb0bb

commit fc1ab22fb3b86093be00c010a57feb1fefceb0bb
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2026-05-08 17:59:54 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2026-05-29 22:59:37 +0000

    Merge commit 871038759afb from llvm git (by Marco Elver):

      Thread Safety Analysis: Fix pointer handling of variables with deprecated
attributes (#148974)

      de10e44b6fe7 ("Thread Safety Analysis: Support warning on
      passing/returning pointers to guarded variables") added checks for
      passing pointer to guarded variables. While new features do not
      necessarily need to support the deprecated attributes (`guarded_var`,
      and `pt_guarded_var`), we need to ensure that such features do not cause
      the compiler to crash.

      As such, code such as this:

              struct {
                int v __attribute__((guarded_var));
              } p;

              int *g() {
                return &p.v;  // handleNoMutexHeld() with POK_ReturnPointer
              }

      Would crash in debug builds with the assertion in handleNoMutexHeld()
      triggering. The assertion is meant to capture the fact that this helper
      should only be used for warnings on variables (which the deprecated
      attributes only applied to).

      To fix, the function handleNoMutexHeld() should handle all POK cases
      that apply to variables explicitly, and produce a best-effort warning.

      We refrain from introducing new warnings to avoid unnecessary code bloat
      for deprecated features.

      Fixes: https://github.com/llvm/llvm-project/issues/140330

    This fixes an assertion while building the net/openvswitch port:
    "Assertion failed: ((POK == POK_VarAccess || POK == POK_VarDereference)
    && "Only works for variables"), function handleNoMutexHeld, file
    /usr/src/contrib/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp,
    line 2120.'

    Reported by:    cy
    PR:             295101, 292067
    MFC after:      1 month

    (cherry picked from commit d9b272a19d39f71665b529860bfed731bcfd99f5)

 .../clang/lib/Sema/AnalysisBasedWarnings.cpp       | 25 +++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

-- 
You are receiving this mail because:
You are the assignee for the bug.