Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Debug Info][IPSCCP] DebugInfoFinder Crash #122350

Open
aeubanks opened this issue Jan 9, 2025 · 5 comments
Open

[Debug Info][IPSCCP] DebugInfoFinder Crash #122350

aeubanks opened this issue Jan 9, 2025 · 5 comments
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] debuginfo

Comments

@aeubanks
Copy link
Contributor

aeubanks commented Jan 9, 2025

$ opt -p ipsccp /tmp/d.ll -disable-output

opt: ../../llvm/include/llvm/Support/Casting.h:662: decltype(auto) llvm::dyn_cast(From *) [To = llvm::DIType, From = llvm::Metadata]: Assertion `detail::isPresent(Val) && "dyn_cast on a non-existent value"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.                                
Stack dump:                                                                                                                                              
0.      Program arguments: build/rel/bin/opt --passes ipsccp /tmp/d.ll -disable-output                                                            
1.      Running pass "ipsccp" on module "/tmp/d.ll"                                                                                                                                                                                                                                                                
 #0 0x000055a905970478 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/lib/Support/Unix/Signals.inc:723:13                                                                   
 #1 0x000055a90596e0be llvm::sys::RunSignalHandlers() /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/lib/Support/Signals.cpp:106:18
 #2 0x000055a905970b08 SignalHandler(int) /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/lib/Support/Unix/Signals.inc:413:1                                                                                                                                                               
 #3 0x00007fd3b3a29590 (/lib/x86_64-linux-gnu/libc.so.6+0x3f590)                                                                                                                                                                                                                                                   
 #4 0x00007fd3b3a783ac __pthread_kill_implementation ./nptl/pthread_kill.c:44:76                                                          
 #5 0x00007fd3b3a294f2 raise ./signal/../sysdeps/posix/raise.c:27:6                                                                                      
 #6 0x00007fd3b3a124ed abort ./stdlib/abort.c:81:7                                                                                                       
 #7 0x00007fd3b3a12415 _nl_load_domain ./intl/loadmsgcat.c:1177:9                                                                                                                                                                                                                                                  
 #8 0x00007fd3b3a22012 (/lib/x86_64-linux-gnu/libc.so.6+0x38012)
 #9 0x000055a905a8ce1c cast_if_present<llvm::DIScope, llvm::Metadata> /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/Support/Casting.h:706:3
#10 0x000055a905a8ce1c cast_or_null<llvm::DIScope, llvm::Metadata> /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/Support/Casting.h:729:10                                                           
#11 0x000055a905a8ce1c getScope /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/IR/DebugInfoMetadata.h:762:38                                                                                                                                                                 
#12 0x000055a905a8ce1c llvm::DebugInfoFinder::processType(llvm::DIType*) /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/lib/IR/DebugInfo.cpp:284:20
#13 0x000055a905a8ccd8 operator++ /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/IR/DebugInfoMetadata.h:109:7                                                                                                                                                                
#14 0x000055a905a8ccd8 llvm::DebugInfoFinder::processType(llvm::DIType*) /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/lib/IR/DebugInfo.cpp:286:22                                                                                                                    
#15 0x000055a905a8c2b1 getNumOperands /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/IR/Metadata.h:1168:12                                                                                                                                                                   
#16 0x000055a905a8c2b1 getNumOperands /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/IR/Metadata.h:1436:56       
#17 0x000055a905a8c2b1 getRawTemplateParams /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/IR/DebugInfoMetadata.h:1952:12
#18 0x000055a905a8c2b1 getTemplateParams /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/IR/DebugInfoMetadata.h:1922:34                                                                                                                                                       
#19 0x000055a905a8c2b1 llvm::DebugInfoFinder::processSubprogram(llvm::DISubprogram*) /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/lib/IR/DebugInfo.cpp:345:28                   
#20 0x000055a905a8cd77 operator++ /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/IR/Metadata.h:1613:5
#21 0x000055a905a8cd77 llvm::DebugInfoFinder::processType(llvm::DIType*) /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/lib/IR/DebugInfo.cpp:292:22
...

d.ll.txt

@EugeneZelenko EugeneZelenko added debuginfo crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Jan 9, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 9, 2025

@llvm/issue-subscribers-debuginfo

Author: Arthur Eubanks (aeubanks)

``` $ opt -p ipsccp /tmp/d.ll -disable-output

opt: ../../llvm/include/llvm/Support/Casting.h:662: decltype(auto) llvm::dyn_cast(From *) [To = llvm::DIType, From = llvm::Metadata]: Assertion `detail::isPresent(Val) && "dyn_cast on a non-existent value"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: build/rel/bin/opt --passes ipsccp /tmp/d.ll -disable-output

  1.  Running pass "ipsccp" on module "/tmp/d.ll"                                                                                                                                                                                                                                                                
    

#0 0x000055a905970478 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/lib/Support/Unix/Signals.inc:723:13
#1 0x000055a90596e0be llvm::sys::RunSignalHandlers() /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/lib/Support/Signals.cpp:106:18
#2 0x000055a905970b08 SignalHandler(int) /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/lib/Support/Unix/Signals.inc:413:1
#3 0x00007fd3b3a29590 (/lib/x86_64-linux-gnu/libc.so.6+0x3f590)
#4 0x00007fd3b3a783ac __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x00007fd3b3a294f2 raise ./signal/../sysdeps/posix/raise.c:27:6
#6 0x00007fd3b3a124ed abort ./stdlib/abort.c:81:7
#7 0x00007fd3b3a12415 _nl_load_domain ./intl/loadmsgcat.c:1177:9
#8 0x00007fd3b3a22012 (/lib/x86_64-linux-gnu/libc.so.6+0x38012)
#9 0x000055a905a8ce1c cast_if_present<llvm::DIScope, llvm::Metadata> /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/Support/Casting.h:706:3
#10 0x000055a905a8ce1c cast_or_null<llvm::DIScope, llvm::Metadata> /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/Support/Casting.h:729:10
#11 0x000055a905a8ce1c getScope /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/IR/DebugInfoMetadata.h:762:38
#12 0x000055a905a8ce1c llvm::DebugInfoFinder::processType(llvm::DIType*) /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/lib/IR/DebugInfo.cpp:284:20
#13 0x000055a905a8ccd8 operator++ /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/IR/DebugInfoMetadata.h:109:7
#14 0x000055a905a8ccd8 llvm::DebugInfoFinder::processType(llvm::DIType*) /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/lib/IR/DebugInfo.cpp:286:22
#15 0x000055a905a8c2b1 getNumOperands /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/IR/Metadata.h:1168:12
#16 0x000055a905a8c2b1 getNumOperands /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/IR/Metadata.h:1436:56
#17 0x000055a905a8c2b1 getRawTemplateParams /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/IR/DebugInfoMetadata.h:1952:12
#18 0x000055a905a8c2b1 getTemplateParams /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/IR/DebugInfoMetadata.h:1922:34
#19 0x000055a905a8c2b1 llvm::DebugInfoFinder::processSubprogram(llvm::DISubprogram*) /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/lib/IR/DebugInfo.cpp:345:28
#20 0x000055a905a8cd77 operator++ /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/include/llvm/IR/Metadata.h:1613:5
#21 0x000055a905a8cd77 llvm::DebugInfoFinder::processType(llvm::DIType*) /usr/local/google/home/aeubanks/repos/llvm-project/build/rel/../../llvm/lib/IR/DebugInfo.cpp:292:22
...


[d.ll.txt](https://github.com/user-attachments/files/18366410/d.ll.txt)

</details>

@aeubanks
Copy link
Contributor Author

aeubanks commented Jan 9, 2025

@jmorse @SLTozer

@aeubanks
Copy link
Contributor Author

aeubanks commented Jan 9, 2025

this seems to be caused by #118710

@SLTozer
Copy link
Contributor

SLTozer commented Jan 9, 2025

At a glance, it looks like the .ll file contains a !DICompositeType with a null element, which breaks assumptions made by existing code.

!2993 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__split_buffer<std::__Cr::basic_string<char,std::__Cr::char_traits<char>,std::__Cr::allocator<char> >,std::__Cr::allocator<std::__Cr::basic_string<char,std::__Cr::char_traits<char>,std::__Cr::allocator<char> > > &>", scope: !5, file: !751, line: 52, size: 320, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !2994, templateParams: !3107, identifier: ".?AU?$__split_buffer@V?$basic_string@DU?$char_traits@D@__Cr@std@@V?$allocator@D@23@@__Cr@std@@AEAV?$allocator@V?$basic_string@DU?$char_traits@D@__Cr@std@@V?$allocator@D@23@@__Cr@std@@@23@@__Cr@std@@")
!2994 = !{!2995, !2996, !2705, !2738, !2998, !3000, !3003, !3004, !3005, !3006, !3007, !3008, null, !3009, !3010, !3011, !3012, !3013, !3014, !3015, !3021, !3024, !3027, !3030, !3035, !3038, !3042, !3045, !3048, !3049, !3052, !3056, !3057, !3058, !3059, !3062, !3065, !3066, !3067, !3068, !3071, !3074, !3075, !3076, !3077, !3078, !3079, !3082, !3085, !3088, !3091, !3094, !3095, !3096, !3097, !3100, !3101, !3104}

The error definitely exists prior to the .ll being produced, which by the looks of things comes down to the libc change? It's not clear where the null element would be generated, potentially the use of opt bisect would make it clearer.

Edit: Alternatively looking at the linked issue, the origin seems to be related to __attribute__((__nodebug__)) - it's possible that null metadata should be handled there (and elsewhere) and this is just a blind spot.

@dwblaikie
Copy link
Collaborator

A reduced source input (rather than opt bisect) is what I'd be hoping for - knowing whether the IR clang generates is reasonable will help point us to where the fix should be (in clang or in some LLVM pass, etc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] debuginfo
Projects
None yet
Development

No branches or pull requests

5 participants