[clang] Reland #90786 ([BoundsSafety] Allow 'counted_by' attribute on pointers in structs in C) (PR #93121)

Dan Liew via cfe-commits cfe-commits at lists.llvm.org
Wed May 22 23:10:12 PDT 2024


delcypher wrote:

Okay this is interesting...

```
********************
FAIL: Clang :: SemaObjC/warn-thread-safety-analysis.m (15515 of 19369)
******************** TEST 'Clang :: SemaObjC/warn-thread-safety-analysis.m' FAILED ********************
Exit Code: 134

Command Output (stderr):
--
RUN: at line 1: /Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang -cc1 -internal-isystem /Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/lib/clang/19/include -nostdsysteminc -fsyntax-only -verify -Wthread-safety -Wthread-safety-beta -Wno-objc-root-class /Volumes/user_data/dev/llvm/llvm.org/main/src/llvm-project/clang/test/SemaObjC/warn-thread-safety-analysis.m
+ /Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang -cc1 -internal-isystem /Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/lib/clang/19/include -nostdsysteminc -fsyntax-only -verify -Wthread-safety -Wthread-safety-beta -Wno-objc-root-class /Volumes/user_data/dev/llvm/llvm.org/main/src/llvm-project/clang/test/SemaObjC/warn-thread-safety-analysis.m
Unhandled late parsed attribute
UNREACHABLE executed at /Volumes/user_data/dev/llvm/llvm.org/main/src/llvm-project/clang/lib/Parse/ParseDecl.cpp:4990!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang -cc1 -internal-isystem /Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/lib/clang/19/include -nostdsysteminc -fsyntax-only -verify -Wthread-safety -Wthread-safety-beta -Wno-objc-root-class /Volumes/user_data/dev/llvm/llvm.org/main/src/llvm-project/clang/test/SemaObjC/warn-thread-safety-analysis.m
1.      /Volumes/user_data/dev/llvm/llvm.org/main/src/llvm-project/clang/test/SemaObjC/warn-thread-safety-analysis.m:7:61: current parser token '('
 #0 0x0000000107d741b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang-19+0x1035d41b8)
 #1 0x0000000107d7479c PrintStackTraceSignalHandler(void*) (/Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang-19+0x1035d479c)
 #2 0x0000000107d72454 llvm::sys::RunSignalHandlers() (/Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang-19+0x1035d2454)
 #3 0x0000000107d758b8 SignalHandler(int) (/Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang-19+0x1035d58b8)
 #4 0x00000001813b9a24 (/usr/lib/system/libsystem_platform.dylib+0x18046da24)
 #5 0x0000000181389cc0 (/usr/lib/system/libsystem_pthread.dylib+0x18043dcc0)
 #6 0x0000000181295a40 (/usr/lib/system/libsystem_c.dylib+0x180349a40)
 #7 0x0000000107c4f0dc llvm::install_out_of_memory_new_handler() (/Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang-19+0x1034af0dc)
 #8 0x000000010c40fc90 clang::Parser::ParseLexedCAttribute(clang::Parser::LateParsedAttribute&, clang::ParsedAttributes*) (/Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang-19+0x107c6fc90)
 #9 0x000000010c3ed5ec clang::Parser::ParseLexedAttributeList(clang::Parser::LateParsedAttrList&, clang::Decl*, bool, bool) (/Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang-19+0x107c4d5ec)
#10 0x000000010c51a05c clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang-19+0x107d7a05c)
#11 0x000000010c400bb8 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang-19+0x107c60bb8)
#12 0x000000010c5190bc clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang-19+0x107d790bc)
#13 0x000000010c5185f4 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang-19+0x107d785f4)
#14 0x000000010c5177f0 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang-19+0x107d777f0)
#15 0x000000010c5158cc clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang-19+0x107d758cc)
#16 0x000000010c3e5808 clang::ParseAST(clang::Sema&, bool, bool) (/Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang-19+0x107c45808)
#17 0x00000001095652b8 clang::ASTFrontendAction::ExecuteAction() (/Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang-19+0x104dc52b8)
#18 0x0000000109564a74 clang::FrontendAction::Execute() (/Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang-19+0x104dc4a74)
#19 0x0000000109484230 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang-19+0x104ce4230)
#20 0x0000000109689944 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang-19+0x104ee9944)
#21 0x00000001047b2dec cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang-19+0x100012dec)
#22 0x00000001047a48c8 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) (/Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang-19+0x1000048c8)
#23 0x00000001047a35fc clang_main(int, char**, llvm::ToolContext const&) (/Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang-19+0x1000035fc)
#24 0x00000001047dc5a4 main (/Volumes/user_data/dev/llvm/llvm.org/main/builds/Debug_xc___sccache/bin/clang-19+0x10003c5a4)
#25 0x00000001810090e0 
```

This means `clang::Parser::ParseLexedAttributeList` (and hence `clang::Parser::ParseLexedAttribute` is actually used for parsing C files. I had assumed it was for C++ only but that's clearly not the case.

I'm going to redo the memory leak patch to not use `clang::Parser::ParseLexedAttributeList` just so we can get the code relanded but after that we should investigate using `clang::Parser::ParseLexedAttributeList` and `clang::Parser::ParseLexedAttribute` so we can get better code reuse.

https://github.com/llvm/llvm-project/pull/93121


More information about the cfe-commits mailing list