[clang] [Clang] Fix a crash when dumping a pack indexing type. (PR #80439)

Björn Pettersson via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 4 01:25:08 PST 2024


bjope wrote:

Seems like this didn't really solve the problem reported by @bevin-hansson (at least not completely).
The new test case fails for us:

```
FAIL: Clang :: AST/ast-dump-pack-indexing-crash.cpp (401 of 78930)
******************** TEST 'Clang :: AST/ast-dump-pack-indexing-crash.cpp' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: not /build/bin/clang -cc1 -internal-isystem /build/lib/clang/19/include -nostdsysteminc -std=c++2c -ast-dump /llvm-project/clang/test/AST/ast-dump-pack-indexing-crash.cpp | /build/bin/FileCheck  /llvm-project/clang/test/AST/ast-dump-pack-indexing-crash.cpp
+ not /build/bin/clang -cc1 -internal-isystem /build/lib/clang/19/include -nostdsysteminc -std=c++2c -ast-dump /llvm-project/clang/test/AST/ast-dump-pack-indexing-crash.cpp
+ /build/bin/FileCheck /llvm-project/clang/test/AST/ast-dump-pack-indexing-crash.cpp
/llvm-project/clang/test/AST/ast-dump-pack-indexing-crash.cpp:9:5: error: i does not refer to the name of a parameter pack
    9 |     i...[0]; // expected-error {{i does not refer to the name of a parameter pack}}
      |     ^
/llvm-project/clang/test/AST/ast-dump-pack-indexing-crash.cpp:10:5: error: V does not refer to the name of a parameter pack
   10 |     V...[0]; // expected-error {{V does not refer to the name of a parameter pack}}
      |     ^
/llvm-project/clang/test/AST/ast-dump-pack-indexing-crash.cpp:11:5: error: 'NotAPack' does not refer to the name of a parameter pack
   11 |     NotAPack...[0] a; // expected-error{{'NotAPack' does not refer to the name of a parameter pack}}
      |     ^
Stack dump:
0.	Program arguments: /build/bin/clang -cc1 -internal-isystem /build/lib/clang/19/include -nostdsysteminc -std=c++2c -ast-dump /llvm-project/clang/test/AST/ast-dump-pack-indexing-crash.cpp
1.	/llvm-project/clang/test/AST/ast-dump-pack-indexing-crash.cpp:11:21: current parser token ';'
2.	/llvm-project/clang/test/AST/ast-dump-pack-indexing-crash.cpp:3:1: parsing namespace 'InvalidPacksShouldNotCrash'
3.	/llvm-project/clang/test/AST/ast-dump-pack-indexing-crash.cpp:7:17: parsing function body 'InvalidPacksShouldNotCrash::not_pack'
4.	/llvm-project/clang/test/AST/ast-dump-pack-indexing-crash.cpp:7:17: in compound statement ('{}')
  #0 0x0000000003b147c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/build/bin/clang+0x3b147c8)
  #1 0x0000000003b11f1c SignalHandler(int) Signals.cpp:0:0
  #2 0x00007f49db4aa630 __restore_rt sigaction.c:0:0
  #3 0x00000000071e19f0 clang::PackIndexingType::getSelectedIndex() const (.part.0) Type.cpp:0:0
  #4 0x0000000006c9e257 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/build/bin/clang+0x6c9e257)
  #5 0x0000000006c86ca7 clang::ASTContext::getTypeInfo(clang::Type const*) const (/build/bin/clang+0x6c86ca7)
  #6 0x0000000006c9e21b clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/build/bin/clang+0x6c9e21b)
  #7 0x0000000006c86ca7 clang::ASTContext::getTypeInfo(clang::Type const*) const (/build/bin/clang+0x6c86ca7)
  #8 0x0000000006c9e21b clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/build/bin/clang+0x6c9e21b)
  #9 0x0000000006c86ca7 clang::ASTContext::getTypeInfo(clang::Type const*) const (/build/bin/clang+0x6c86ca7)
 #10 0x0000000006c9e21b clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/build/bin/clang+0x6c9e21b)
 #11 0x0000000006c86ca7 clang::ASTContext::getTypeInfo(clang::Type const*) const (/build/bin/clang+0x6c86ca7)
 #12 0x0000000006c9e21b clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/build/bin/clang+0x6c9e21b)
 #13 0x0000000006c86ca7 clang::ASTContext::getTypeInfo(clang::Type const*) const (/build/bin/clang+0x6c86ca7)
 #14 0x0000000006c9e21b clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/build/bin/clang+0x6c9e21b)
 #15 0x0000000006c86ca7 clang::ASTContext::getTypeInfo(clang::Type const*) const (/build/bin/clang+0x6c86ca7)
 #16 0x0000000006c9e21b clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/build/bin/clang+0x6c9e21b)
 #17 0x0000000006c86ca7 clang::ASTContext::getTypeInfo(clang::Type const*) const (/build/bin/clang+0x6c86ca7)
 #18 0x0000000006c9e21b clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/build/bin/clang+0x6c9e21b)
 #19 0x0000000006c86ca7 clang::ASTContext::getTypeInfo(clang::Type const*) const (/build/bin/clang+0x6c86ca7)
 #20 0x0000000006c9e21b clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/build/bin/clang+0x6c9e21b)
 #21 0x0000000006c86ca7 clang::ASTContext::getTypeInfo(clang::Type const*) const (/build/bin/clang+0x6c86ca7)
 #22 0x0000000006c9e21b clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/build/bin/clang+0x6c9e21b)
 #23 0x0000000006c86ca7 clang::ASTContext::getTypeInfo(clang::Type const*) const (/build/bin/clang+0x6c86ca7)
 #24 0x0000000006c9e21b clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/build/bin/clang+0x6c9e21b)
 #25 0x0000000006c86ca7 clang::ASTContext::getTypeInfo(clang::Type const*) const (/build/bin/clang+0x6c86ca7)
 #26 0x0000000006c9e21b clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/build/bin/clang+0x6c9e21b)
 #27 0x0000000006c86ca7 clang::ASTContext::getTypeInfo(clang::Type const*) const (/build/bin/clang+0x6c86ca7)
 #28 0x0000000006c9e21b clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/build/bin/clang+0x6c9e21b)
 #29 0x0000000006c86ca7 clang::ASTContext::getTypeInfo(clang::Type const*) const (/build/bin/clang+0x6c86ca7)
 #30 0x0000000006c9e21b clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/build/bin/clang+0x6c9e21b)
 #31 0x0000000006c86ca7 clang::ASTContext::getTypeInfo(clang::Type const*) const (/build/bin/clang+0x6c86ca7)
 #32 0x0000000006c9e21b clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/build/bin/clang+0x6c9e21b)
 #33 0x0000000006c86ca7 clang::ASTContext::getTypeInfo(clang::Type const*) const (/build/bin/clang+0x6c86ca7)
 #34 0x0000000006c9e21b clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/build/bin/clang+0x6c9e21b)
 #35 0x0000000006c86ca7 clang::ASTContext::getTypeInfo(clang::Type const*) const (/build/bin/clang+0x6c86ca7)
 #36 0x0000000006c9e21b clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/build/bin/clang+0x6c9e21b)
 #37 0x0000000006c86ca7 clang::ASTContext::getTypeInfo(clang::Type const*) const (/build/bin/clang+0x6c86ca7)
 ...
```

Well. I don't know that much about this. Just noticed that our downstream bots started to fail on this new test case. Maybe we need to look at it on Monday to give more context, I don't have more info right now at least.

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


More information about the cfe-commits mailing list