[llvm-bugs] [Bug 46861] New: Clang crashed in valid code with a unknow attribute: in clang/lib/Sema/SemaDecl.cpp:5195 Assertion `DS.getAttributes().empty() && "No attribute expected"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 27 05:16:54 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46861

            Bug ID: 46861
           Summary: Clang crashed in valid code with a unknow attribute:
                    in clang/lib/Sema/SemaDecl.cpp:5195 Assertion
                    `DS.getAttributes().empty() && "No attribute
                    expected"' failed
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: haoxintu at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Hi,all.

This valid code (I suspect) makes Clang-trunk crashed. This only occurs on
trunk, but compiles well in other released versions.

Input:
//small.cc
static union {int u;} [[a]];

Command:
clang++ small.cc

Output:
small.cc:1:25: warning: unknown attribute 'a' ignored [-Wunknown-attributes]
static union {int u;} [[a]];
                        ^
clang-12:
/home/tuhaoxin/compilers/llvm-project-0726/clang/lib/Sema/SemaDecl.cpp:5195:
clang::Decl *clang::Sema::BuildAnonymousStructOrUnion(clang::Scope *,
clang::DeclSpec &, clang::AccessSpecifier, clang::RecordDecl *, const
clang::PrintingPolicy &): Assertion `DS.getAttributes().empty() && "No
attribute expected"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments:
/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
small.cc -mrelocation-model static -mframe-pointer=all -fmath-errno
-fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64
-fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir
/home/tuhaoxin/compilers/llvm-project-0726/build/lib/clang/12.0.0 -c-isystem
/usr/local/include/csmith-2.3.0 -cxx-isystem /usr/local/include/csmith-2.3.0
-internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward
-internal-isystem /usr/local/include -internal-isystem
/home/tuhaoxin/compilers/llvm-project-0726/build/lib/clang/12.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdeprecated-macro -fdebug-compilation-dir
/home/tuhaoxin/gitee/run-new-scg/comparison/grammarinator/ice-tests/creduce-clang
-ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions
-fcolor-diagnostics -faddrsig -o /tmp/small-94c89d.o -x c++ small.cc 
1.      <eof> parser at end of file
 #0 0x000000000275ec74 PrintStackTraceSignalHandler(void*)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x275ec74)
 #1 0x000000000275c86e llvm::sys::RunSignalHandlers()
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x275c86e)
 #2 0x000000000275ef95 SignalHandler(int)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x275ef95)
 #3 0x00007fe28c86f8a0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x128a0)
 #4 0x00007fe28b2cdf47 raise
/build/glibc-2ORdQG/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007fe28b2cf8b1 abort /build/glibc-2ORdQG/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007fe28b2bf42a __assert_fail_base
/build/glibc-2ORdQG/glibc-2.27/assert/assert.c:89:0
 #7 0x00007fe28b2bf4a2 (/lib/x86_64-linux-gnu/libc.so.6+0x304a2)
 #8 0x0000000004211591 clang::Sema::BuildAnonymousStructOrUnion(clang::Scope*,
clang::DeclSpec&, clang::AccessSpecifier, clang::RecordDecl*,
clang::PrintingPolicy const&)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x4211591)
 #9 0x000000000420cb68 clang::Sema::ParsedFreeStandingDeclSpec(clang::Scope*,
clang::AccessSpecifier, clang::DeclSpec&, clang::RecordDecl*&)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x420cb68)
#10 0x0000000003fe9c43
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x3fe9c43)
#11 0x0000000003fe9635
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x3fe9635)
#12 0x0000000003fe841f
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x3fe841f)
#13 0x0000000003fe648d
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x3fe648d)
#14 0x0000000003fe5cd7
clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x3fe5cd7)
#15 0x0000000003fe189e clang::ParseAST(clang::Sema&, bool, bool)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x3fe189e)
#16 0x0000000002f3b553 clang::FrontendAction::Execute()
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x2f3b553)
#17 0x0000000002ed2193
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x2ed2193)
#18 0x0000000002fe73f2
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x2fe73f2)
#19 0x0000000000989758 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x989758)
#20 0x00000000009877cc ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x9877cc)
#21 0x0000000000987481 main
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x987481)
#22 0x00007fe28b2b0b97 __libc_start_main
/build/glibc-2ORdQG/glibc-2.27/csu/../csu/libc-start.c:344:0
#23 0x000000000098449a _start
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x98449a)
clang-12: error: unable to execute command: Aborted (core dumped)
clang-12: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 12.0.0 (https://github.com/llvm/llvm-project.git
d135744c34dc7a6315f1d2d65a969a2791a97534)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/tuhaoxin/compilers/llvm-project-0726/build/bin
clang-12: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-12: note: diagnostic msg: /tmp/small-0d1f7d.cpp
clang-12: note: diagnostic msg: /tmp/small-0d1f7d.sh
clang-12: note: diagnostic msg: 

********************

Thanks
Haoxin

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200727/2d559171/attachment.html>


More information about the llvm-bugs mailing list