llvm / llvm/llvm-project

[clangd][clang] Crash in `ASTContext::adjustExceptionSpec` on `TypeLoc::getFullDataSizeForType(Updated) == TypeLoc::getFullDataSizeForType(TSInfo->getType()) && "TypeLoc size mismatch from updating exception specification"' failed.`

Open
#200,580 1 comment 0 reactions 0 assignees View on GitHub
clangd crash generated by fuzzer
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

This is generated by a fuzzer.
I failed to trigger it directly by clang-fronted.
Source code:

```cxx
#include "a"
struct A{
~A() noexcept(false);
};
```
```
initialize -> initialized -> didOpen -> textDocument/signatureHelp->shutdown -> exit
```
The location of signatureHelp is(0-based)
```
- line = 3
- character = 1
```
stack trace:
```
Assertion / headline
- clangd: /tmp/llvm-project-main-20260504/clang/lib/AST/ASTContext.cpp:3873: void clang::ASTContext::adjustExceptionSpec(clang::FunctionDecl*, const clang::FunctionProtoType::ExceptionSpecInfo&, bool): Assertion `TypeLoc::getFullDataSizeForType(Updated) == TypeLoc::getFullDataSizeForType(TSInfo->getType()) && "TypeLoc size mismatch from updating exception specification"' failed.

Top frames
#0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=) at ./nptl/pthread_kill.c:44
#1 __pthread_kill_internal (signo=6, threadid=) at ./nptl/pthread_kill.c:78
#2 __GI___pthread_kill (threadid=, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3 0x00007ffff784527e in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4 0x00007ffff78288ff in __GI_abort () at ./stdlib/abort.c:79
#5 0x00007ffff782881b in __assert_fail_base (fmt=0x7ffff79d01e8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x555557fdae28 "TypeLoc::getFullDataSizeForType(Updated) == TypeLoc::getFullDataSizeForType(TSInfo->getType()) && \"TypeLoc size mismatch from updating exception specification\"", file=file@entry=0x555557fc7178 "/tmp/llvm-project-main-20260504/clang/lib/AST/ASTContext.cpp", line=line@entry=3873, function=function@entry=0x555557fdada8 "void clang::ASTContext::adjustExceptionSpec(clang::FunctionDecl*, const clang::FunctionProtoType::ExceptionSpecInfo&, bool)") at ./assert/assert.c:96
#6 0x00007ffff783b517 in __assert_fail (assertion=0x555557fdae28 "TypeLoc::getFullDataSizeForType(Updated) == TypeLoc::getFullDataSizeForType(TSInfo->getType()) && \"TypeLoc size mismatch from updating exception specification\"", file=0x555557fc7178 "/tmp/llvm-project-main-20260504/clang/lib/AST/ASTContext.cpp", line=3873, function=0x555557fdada8 "void clang::ASTContext::adjustExceptionSpec(clang::FunctionDecl*, const clang::FunctionProtoType::ExceptionSpecInfo&, bool)") at ./assert/assert.c:105
#7 0x0000555555a5974e in clang::ASTContext::adjustExceptionSpec (this=0x7fffac05a560, FD=, ESI=..., AsWritten=) at /tmp/llvm-project-main-20260504/clang/lib/AST/ASTContext.cpp:3873
#8 0x00005555569010af in clang::Sema::actOnDelayedExceptionSpecification (this=0x7fffac0b88d0, D=0x7fffac0be340, EST=clang::EST_DependentNoexcept, SpecificationRange=..., DynamicExceptions=..., DynamicExceptionRanges=..., NoexceptExpr=0x7) at /tmp/llvm-project-main-20260504/clang/lib/Sema/SemaDeclCXX.cpp:19631
#9 0x000055555787ac40 in clang::Parser::ParseLexedMethodDeclaration (this=0x7fffac050850, LM=...) at /tmp/llvm-project-main-20260504/llvm/include/llvm/ADT/SmallVector.h:83
#10 0x00005555578702bd in clang::Parser::ParseLexedMethodDeclarations (this=this@entry=0x7fffac050850, Class=...) at /tmp/llvm-project-main-20260504/clang/lib/Parse/ParseCXXInlineMethods.cpp:369
#11 0x00005555578bfb24 in clang::Parser::ParseCXXMemberSpecification (this=0x7fffac050850, RecordLoc=..., AttrFixitLoc=..., Attrs=..., TagType=, TagDecl=) at /tmp/llvm-project-main-20260504/clang/lib/Parse/ParseDeclCXX.cpp:3720
#12 0x00005555578c1f3c in clang::Parser::ParseClassSpecifier (this=this@entry=0x7fffac050850, TagTokKind=, TagTokKind@entry=clang::tok::kw_struct, StartLoc=..., DS=..., TemplateInfo=..., AS=AS@entry=clang::AS_none, EnteringContext=true, DSC=clang::Parser::DeclSpecContext::DSC_top_level, Attributes=...) at /tmp/llvm-project-main-20260504/clang/lib/Parse/ParseDeclCXX.cpp:2179
#13 0x000055555788cd7f in clang::Parser::ParseDeclarationSpecifiers (this=this@entry=0x7fffac050850, DS=..., TemplateInfo=..., AS=AS@entry=clang::AS_none, DSContext=, DSContext@entry=clang::Parser::DeclSpecContext::DSC_top_level, LateAttrs=LateAttrs@entry=0x0, AllowImplicitTypename=clang::ImplicitTypenameContext::Yes) at /tmp/llvm-project-main-20260504/clang/lib/Parse/ParseDecl.cpp:4509
#14 0x000055555785bf3e in clang::Parser::ParseDeclarationSpecifiers (LateAttrs=0x0, DSC=clang::Parser::DeclSpecContext::DSC_top_level, AS=clang::AS_none, TemplateInfo=..., DS=..., this=0x7fffac050850) at /tmp/llvm-project-main-20260504/clang/include/clang/Parse/Parser.h:1841
#15 clang::Parser::ParseDeclOrFunctionDefInternal (this=0x7fffac050850, Attrs=..., DeclSpecAttrs=..., DS=..., AS=) at /tmp/llvm-project-main-20260504/clang/lib/Parse/Parser.cpp:1062
#16 0x000055555785ca7f in clang::Parser::ParseDeclarationOrFunctionDefinition (this=0x7fffac050850, Attrs=..., DeclSpecAttrs=..., DS=, AS=) at /tmp/llvm-project-main-20260504/clang/lib/Parse/Parser.cpp:1175
#17 0x0000555557863571 in clang::Parser::ParseExternalDeclaration (this=0x7fffac050850, Attrs=..., DeclSpecAttrs=..., DS=0x0) at /tmp/llvm-project-main-20260504/clang/lib/Parse/Parser.cpp:1003
#18 0x0000555557865237 in clang::Parser::ParseTopLevelDecl (this=0x7fffac050850, Result=..., ImportState=@0x7fffbb7fd384: clang::Sema::ModuleImportState::FirstDecl) at /tmp/llvm-project-main-20260504/clang/lib/Parse/Parser.cpp:711
#19 0x00005555578656d3 in clang::Parser::ParseFirstTopLevelDecl (this=this@entry=0x7fffac050850, Result=..., ImportState=@0x7fffbb7fd384: clang::Sema::ModuleImportState::FirstDecl) at /tmp/llvm-project-main-20260504/clang/lib/Parse/Parser.cpp:600
#20 0x0000555557849aaa in clang::ParseAST (S=..., PrintStats=false, SkipFunctionBodies=) at /tmp/llvm-project-main-20260504/clang/lib/Parse/ParseAST.cpp:169
#21 0x00005555576436e7 in clang::FrontendAction::Execute (this=this@entry=0x7fffbb7fd590) at /tmp/llvm-project-main-20260504/clang/lib/Frontend/FrontendAction.cpp:1342
#22 0x0000555556ea283c in clang::clangd::(anonymous namespace)::semaCodeComplete (Consumer=std::unique_ptr = {...}, Options=..., Input=..., Includes=Includes@entry=0x0) at /tmp/llvm-project-main-20260504/clang-tools-extra/clangd/CodeComplete.cpp:1464
#23 0x0000555556ea3dbc in clang::clangd::signatureHelp (FileName=..., Pos=..., Preamble=..., ParseInput=..., DocumentationFormat=clang::clangd::MarkupKind::PlainText) at /tmp/llvm-project-main-20260504/clang-tools-extra/clangd/CodeComplete.cpp:2353
#24 0x0000555556e8197c in operator() (__closure=0x55555901a3e0, IP=...) at /usr/include/c++/13/bits/basic_string.h:1078
#25 0x0000555556e81f03 in llvm::detail::UniqueFunctionBase >::CallImpl)::)> >(void *, llvm::detail::UniqueFunctionBase >::AdjustedParamT) (CallableAddr=, Params#0=...) at /tmp/llvm-project-main-20260504/llvm/include/llvm/ADT/FunctionExtras.h:212
#26 0x00005555570c82eb in llvm::unique_function)>::operator()(llvm::Expected) (Params#0=..., this=0x55555900f3b0) at /tmp/llvm-project-main-20260504/llvm/include/llvm/ADT/FunctionExtras.h:364
#27 operator() (__closure=0x55555900f290) at /tmp/llvm-project-main-20260504/clang-tools-extra/clangd/TUScheduler.cpp:1810
#28 0x00005555572a6b6e in llvm::unique_function::operator()() (this=0x555558ff3810) at /tmp/llvm-project-main-20260504/llvm/include/llvm/ADT/FunctionExtras.h:364
#29 operator() (__closure=0x555558ff37f0) at /tmp/llvm-project-main-20260504/clang-tools-extra/clangd/support/Threading.cpp:101
#30 operator())::&> (F=..., __closure=) at /tmp/llvm-project-main-20260504/llvm/include/llvm/Support/thread.h:46
#31 std::__invoke_impl):: > >(void*)::, clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function)::&> (__f=...) at /usr/include/c++/13/bits/invoke.h:61
#32 std::__invoke):: > >(void*)::, clang::clangd::AsyncTaskRunner::runAsync(const llvm::Twine&, llvm::unique_function)::&> (__fn=...) at /usr/include/c++/13/bits/invoke.h:96
#33 std::__apply_impl):: > >(void*)::, std::tuple):: >&, 0> (__t=std::tuple containing = {...}, __f=...) at /usr/include/c++/13/tuple:2302
#34 std::apply):: > >(void*)::, std::tuple):: >&> (__t=std::tuple containing = {...}, __f=...) at /usr/include/c++/13/tuple:2313
#35 llvm::thread::GenericThreadProxy):: > > (Ptr=0x555558ff37f0) at /tmp/llvm-project-main-20260504/llvm/include/llvm/Support/thread.h:44
#36 llvm::thread::ThreadProxy):: > >(void *) (Ptr=0x555558ff37f0) at /tmp/llvm-project-main-20260504/llvm/include/llvm/Support/thread.h:62
#37 0x00007ffff789caa4 in start_thread (arg=) at ./nptl/pthread_create.c:447
#38 0x00007ffff7929c6c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
#0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=) at ./nptl/pthread_kill.c:44
#1 __pthread_kill_internal (signo=6, threadid=) at ./nptl/pthread_kill.c:78
#2 __GI___pthread_kill (threadid=, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3 0x00007ffff784527e in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4 0x00007ffff78288ff in __GI_abort () at ./stdlib/abort.c:79
#5 0x00007ffff782881b in __assert_fail_base (fmt=0x7ffff79d01e8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x555557fdae28 "TypeLoc::getFullDataSizeForType(Updated) == TypeLoc::getFullDataSizeForType(TSInfo->getType()) && \"TypeLoc size mismatch from updating exception specification\"", file=file@entry=0x555557fc7178 "/tmp/llvm-project-main-20260504/clang/lib/AST/ASTContext.cpp", line=line@entry=3873, function=function@entry=0x555557fdada8 "void clang::ASTContext::adjustExceptionSpec(clang::FunctionDecl*, const clang::FunctionProtoType::ExceptionSpecInfo&, bool)") at ./assert/assert.c:96
#6 0x00007ffff783b517 in __assert_fail (assertion=0x555557fdae28 "TypeLoc::getFullDataSizeForType(Updated) == TypeLoc::getFullDataSizeForType(TSInfo->getType()) && \"TypeLoc size mismatch from updating exception specification\"", file=0x555557fc7178 "/tmp/llvm-project-main-20260504/clang/lib/AST/ASTContext.cpp", line=3873, function=0x555557fdada8 "void clang::ASTContext::adjustExceptionSpec(clang::FunctionDecl*, const clang::FunctionProtoType::ExceptionSpecInfo&, bool)") at ./assert/assert.c:105
#7 0x0000555555a5974e in clang::ASTContext::adjustExceptionSpec (this=0x7fffac05a560, FD=, ESI=..., AsWritten=) at /tmp/llvm-project-main-20260504/clang/lib/AST/ASTContext.cpp:3873
#8 0x00005555569010af in clang::Sema::actOnDelayedExceptionSpecification (this=0x7fffac0b88d0, D=0x7fffac0be340, EST=clang::EST_DependentNoexcept, SpecificationRange=..., DynamicExceptions=..., DynamicExceptionRanges=..., NoexceptExpr=0x7) at /tmp/llvm-project-main-20260504/clang/lib/Sema/SemaDeclCXX.cpp:19631
#9 0x000055555787ac40 in clang::Parser::ParseLexedMethodDeclaration (this=0x7fffac050850, LM=...) at /tmp/llvm-project-main-20260504/llvm/include/llvm/ADT/SmallVector.h:83
#10 0x00005555578702bd in clang::Parser::ParseLexedMethodDeclarations (this=this@entry=0x7fffac050850, Class=...) at /tmp/llvm-project-main-20260504/clang/lib/Parse/ParseCXXInlineMethods.cpp:369
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.