In message <[email protected]>, Dimitry Andric writes : > The branch main has been updated by dim: > > URL: https://cgit.FreeBSD.org/src/commit/?id=d9b272a19d39f71665b529860bfed731 > bcfd99f5 > > commit d9b272a19d39f71665b529860bfed731bcfd99f5 > Author: Dimitry Andric <[email protected]> > AuthorDate: 2026-05-08 17:59:54 +0000 > Commit: Dimitry Andric <[email protected]> > CommitDate: 2026-05-08 17:59:54 +0000 > > Merge commit 871038759afb from llvm git (by Marco Elver): > > Thread Safety Analysis: Fix pointer handling of variables with deprecat > ed 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 caus > e > 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 bloa > t > 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 > --- > .../clang/lib/Sema/AnalysisBasedWarnings.cpp | 25 +++++++++++++++++--- > -- > 1 file changed, 20 insertions(+), 5 deletions(-) > > diff --git a/contrib/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp b/ > contrib/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp > index ec39bca6039f..ab55cbceeaa8 100644 > --- a/contrib/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp > +++ b/contrib/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp > @@ -2116,11 +2116,26 @@ class ThreadSafetyReporter : public clang::threadSafe > ty::ThreadSafetyHandler { > > void handleNoMutexHeld(const NamedDecl *D, ProtectedOperationKind POK, > AccessKind AK, SourceLocation Loc) override { > - assert((POK == POK_VarAccess || POK == POK_VarDereference) && > - "Only works for variables"); > - unsigned DiagID = POK == POK_VarAccess? > - diag::warn_variable_requires_any_lock: > - diag::warn_var_deref_requires_any_lock; > + unsigned DiagID = 0; > + switch (POK) { > + case POK_VarAccess: > + case POK_PassByRef: > + case POK_ReturnByRef: > + case POK_PassPointer: > + case POK_ReturnPointer: > + DiagID = diag::warn_variable_requires_any_lock; > + break; > + case POK_VarDereference: > + case POK_PtPassByRef: > + case POK_PtReturnByRef: > + case POK_PtPassPointer: > + case POK_PtReturnPointer: > + DiagID = diag::warn_var_deref_requires_any_lock; > + break; > + case POK_FunctionCall: > + llvm_unreachable("Only works for variables"); > + break; > + } > PartialDiagnosticAt Warning(Loc, S.PDiag(DiagID) > << D << getLockKindFromAccessKind(AK)); > Warnings.emplace_back(std::move(Warning), getNotes()); >
After updating the system and the poudriere jail it's still experiencing the same issue. A Snippet of poudriere output below. /bin/sh ./libtool --tag=CC --mode=compile cc -DHAVE_CONFIG_H -I. -I ./include -I ./include -I ./lib -I ./lib -I/usr/include -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -Wthread-safety -fno-strict-aliasing -Wswitch-bool -Wlogical-not-parentheses -Wsizeof-array-argument -Wshift-negative-value -Qunused-arguments -Wshadow -Wno-null-pointer-arithmetic -Warray-bounds-pointer-arithmetic -O2 -pipe -Wno-misleading-indentation -Wno-tautological-overlap-compare -Wno-unused-but-set-variable -Wno-deprecated-literal-operator -Wno-misleading-indentation -Wno-tautological-overlap-compare -Wno-unused-but-set-variable -fstack-protector-strong -fno-strict-aliasing -mno-avx512f -MT lib/util.lo -MD -MP -MF $depbase.Tpo -c -o lib/util.lo lib/util.c &&\ mv -f $depbase.Tpo $depbase.Plo #0 0x000015af6c783b06 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /opt/src/git-src/contrib/llvm-project/llvm/lib/Support/Unix/Signals.inc:0:13 #1 0x000015af6c781543 llvm::sys::RunSignalHandlers() /opt/src/git-src/contrib/llvm-project/llvm/lib/Support/Signals.cpp:105:18 #2 0x000015af6c7255a2 HandleCrash /opt/src/git-src/contrib/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:73:5 #3 0x000015af6c7255a2 CrashRecoverySignalHandler /opt/src/git-src/contrib/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:390:51 #4 0x000015af6f03493c handle_signal /opt/src/git-src/lib/libthr/thread/thr_sig.c:0:3 #5 0x000015af6f033f5b thr_sighandler /opt/src/git-src/lib/libthr/thread/thr_sig.c:262:1 #6 0x000015af60e282d3 ([vdso]+0x2d3) #7 0x000015af74a3fd8a _thr_kill /export/obj/opt/src/git-src/amd64.amd64/lib/libsys/thr_kill.S:4:0 #8 0x000015af71a58a54 raise /opt/src/git-src/lib/libc/gen/raise.c:0:10 #9 0x000015af71b0a769 abort /opt/src/git-src/lib/libc/stdlib/abort.c:67:17 #10 0x000015af71a3b591 (/lib/libc.so.7+0xa2591) #11 0x000015af662b64e6 handleNoMutexHeld /opt/src/git-src/contrib/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp:0:5 #12 0x000015af65576664 hasAttrs /opt/src/git-src/contrib/llvm-project/clang/include/clang/AST/DeclBase.h:521:34 #13 0x000015af65576664 attr_begin /opt/src/git-src/contrib/llvm-project/clang/include/clang/AST/DeclBase.h:543:12 #14 0x000015af65576664 specific_attr_begin<clang::GuardedByAttr> /opt/src/git-src/contrib/llvm-project/clang/include/clang/AST/DeclBase.h:568:38 #15 0x000015af65576664 specific_attrs<clang::GuardedByAttr> /opt/src/git-src/contrib/llvm-project/clang/include/clang/AST/DeclBase.h:563:29 #16 0x000015af65576664 checkAccess /opt/src/git-src/contrib/llvm-project/clang/lib/Analysis/ThreadSafety.cpp:1775:27 #17 0x000015af65577976 examineArguments /opt/src/git-src/contrib/llvm-project/clang/lib/Analysis/ThreadSafety.cpp:2150:35 #18 0x000015af6557594b getCallee /opt/src/git-src/contrib/llvm-project/clang/include/clang/AST/Expr.h:3023:53 #19 0x000015af6557594b getCalleeDecl /opt/src/git-src/contrib/llvm-project/clang/include/clang/AST/Expr.h:3054:12 #20 0x000015af6557594b VisitCallExpr /opt/src/git-src/contrib/llvm-project/clang/lib/Analysis/ThreadSafety.cpp:2223:46 #21 0x000015af6556837b Visit /export/obj/opt/src/git-src/amd64.amd64/lib/clang/libclang/clang/AST/StmtNodes.inc:1622:1 #22 0x000015af6556837b runAnalysis /opt/src/git-src/contrib/llvm-project/clang/lib/Analysis/ThreadSafety.cpp:2655:26 #23 0x000015af655645ee operator() /export/obj/opt/src/git-src/amd64.amd64/tmp/usr/include/c++/v1/__vector/vector.h:250:18 #24 0x000015af655645ee ~vector /export/obj/opt/src/git-src/amd64.amd64/tmp/usr/include/c++/v1/__vector/vector.h:262:67 #25 0x000015af655645ee ~ThreadSafetyAnalyzer /opt/src/git-src/contrib/llvm-project/clang/lib/Analysis/ThreadSafety.cpp:1082:7 #26 0x000015af655645ee clang::threadSafety::runThreadSafetyAnalysis(clang::AnalysisDeclContext&, clang::threadSafety::ThreadSafetyHandler&, clang::threadSafety::BeforeSet**) /opt/src/git-src/contrib/llvm-project/clang/lib/Analysis/ThreadSafety.cpp:2743:1 #27 0x000015af662aa7d6 emitDiagnostics /opt/src/git-src/contrib/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp:1997:44 #28 0x000015af662aa7d6 clang::sema::AnalysisBasedWarnings::IssueWarnings(clang::sema::AnalysisBasedWarnings::Policy, clang::sema::FunctionScopeInfo*, clang::Decl const*, clang::QualType) /opt/src/git-src/contrib/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp:2982:14 #29 0x000015af6634f5e4 clang::Sema::PopFunctionScopeInfo(clang::sema::AnalysisBasedWarnings::Policy const*, clang::Decl const*, clang::QualType) /opt/src/git-src/contrib/llvm-project/clang/lib/Sema/Sema.cpp:2458:3 #30 0x000015af664d892f reset /export/obj/opt/src/git-src/amd64.amd64/tmp/usr/include/c++/v1/__memory/unique_ptr.h:287:21 #31 0x000015af664d892f ~unique_ptr /export/obj/opt/src/git-src/amd64.amd64/tmp/usr/include/c++/v1/__memory/unique_ptr.h:259:71 #32 0x000015af664d892f clang::Sema::ActOnFinishFunctionBody(clang::Decl*, clang::Stmt*, bool) /opt/src/git-src/contrib/llvm-project/clang/lib/Sema/SemaDecl.cpp:16687:3 #33 0x000015af6628555c clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) /opt/src/git-src/contrib/llvm-project/clang/lib/Parse/ParseStmt.cpp:2402:18 #34 0x000015af6629f843 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) /opt/src/git-src/contrib/llvm-project/clang/lib/Parse/Parser.cpp:0:0 #35 0x000015af661ca5bc clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) /opt/src/git-src/contrib/llvm-project/clang/lib/Parse/ParseDecl.cpp:2266:18 #36 0x000015af6629e9bf clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /opt/src/git-src/contrib/llvm-project/clang/lib/Parse/Parser.cpp:0:10 #37 0x000015af6629e1a5 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /opt/src/git-src/contrib/llvm-project/clang/lib/Parse/Parser.cpp:1209:12 #38 0x000015af6629d10a clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) /opt/src/git-src/contrib/llvm-project/clang/lib/Parse/Parser.cpp:0:14 #39 0x000015af6629b8a5 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) /opt/src/git-src/contrib/llvm-project/clang/lib/Parse/Parser.cpp:745:10 #40 0x000015af661b4a4e clang::ParseAST(clang::Sema&, bool, bool) /opt/src/git-src/contrib/llvm-project/clang/lib/Parse/ParseAST.cpp:169:5 #41 0x000015af6601fe48 clang::FrontendAction::Execute() /opt/src/git-src/contrib/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1225:10 #42 0x000015af65fa08cd getPtr /opt/src/git-src/contrib/llvm-project/llvm/include/llvm/Support/Error.h:278:42 #43 0x000015af65fa08cd operator bool /opt/src/git-src/contrib/llvm-project/llvm/include/llvm/Support/Error.h:241:16 #44 0x000015af65fa08cd clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /opt/src/git-src/contrib/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1055:23 #45 0x000015af660c02a5 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /opt/src/git-src/contrib/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:299:25 #46 0x000015af1464f224 cc1_main /opt/src/git-src/contrib/llvm-project/clang/tools/driver/cc1_main.cpp:297:15 #47 0x000015af1465d0a5 ExecuteCC1Tool /opt/src/git-src/contrib/llvm-project/clang/tools/driver/driver.cpp:225:12 #48 0x000015af65c6198e operator() /opt/src/git-src/contrib/llvm-project/clang/lib/Driver/Job.cpp:436:30 #49 0x000015af65c6198e callback_fn<(lambda at /opt/src/git-src/contrib/llvm-project/clang/lib/Driver/Job.cpp:436:22)> /opt/src/git-src/contrib/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:12 #50 0x000015af6c7251fc operator() /opt/src/git-src/contrib/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:0:12 #51 0x000015af6c7251fc llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /opt/src/git-src/contrib/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:426:3 #52 0x000015af65c60f0a clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const /opt/src/git-src/contrib/llvm-project/clang/lib/Driver/Job.cpp:436:7 #53 0x000015af65c20844 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const /opt/src/git-src/contrib/llvm-project/clang/lib/Driver/Compilation.cpp:196:15 #54 0x000015af65c20acc clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&, bool) const /opt/src/git-src/contrib/llvm-project/clang/lib/Driver/Compilation.cpp:251:13 #55 0x000015af65c40186 empty /opt/src/git-src/contrib/llvm-project/llvm/include/llvm/ADT/SmallVector.h:82:46 #56 0x000015af65c40186 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&) /opt/src/git-src/contrib/llvm-project/clang/lib/Driver/Driver.cpp:2246:23 #57 0x000015af1465c76c clang_main /opt/src/git-src/contrib/llvm-project/clang/tools/driver/driver.cpp:406:21 #58 0x000015af1465ae22 main /opt/src/git-src/usr.bin/clang/clang/clang-driver.cpp:17:10 #59 0x000015af71a2d3cf __libc_start1 /opt/src/git-src/lib/libc/csu/libc_start1.c:180:2 cc: error: clang frontend command failed with exit code 134 (use -v to see invocation) FreeBSD clang version 21.1.8 (https://github.com/llvm/llvm-project.git llvmorg-21.1.8-0-g2078da43e25a) Target: x86_64-unknown-freebsd16.0 Thread model: posix InstalledDir: /usr/bin Build config: +assertions cc: note: diagnostic msg: ******************** PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: cc: note: diagnostic msg: /tmp/timeval-562747.c cc: note: diagnostic msg: /tmp/timeval-562747.sh cc: note: diagnostic msg: ******************** Trying this on a physical machine results in the same LLVM panic. -- Cheers, Cy Schubert <[email protected]> FreeBSD UNIX: <[email protected]> Web: https://FreeBSD.org NTP: <[email protected]> Web: https://nwtime.org e**(i*pi)+1=0
