[clang-refactor] Assertion failure in SourceManager::getFileIDLoaded during local-rename on valid C++ code
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
This input is generated by a fuzzer.
Seems to be a valid input?
```cxx
#include
void f(int n) {
std::vector v;
auto it = std::begin(v);
v.resize(n);
*it;
}
```
```
clang-refactor \
local-rename \
-selection=test.cpp:4:18 \
--new-name=renamed_symbol \
test.cpp \
-- clang++ -std=c++26 -fsyntax-only \
test.cpp
```
```
clang-refactor: clang/lib/Basic/SourceManager.cpp:886: FileID clang::SourceManager::getFileIDLoaded(SourceLocation::UIntTy) const: Assertion `0 && "Invalid SLocOffset or bad function choice"' failed.
#0 0x0000599ed61c998a ___interceptor_backtrace (+0x122198a)
#1 0x0000599ed64dd666 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
#2 0x0000599ed64d1e28 llvm::sys::RunSignalHandlers()
#3 0x0000599ed64e2ca8 SignalHandler(int, siginfo_t*, void*)
#4 0x000078c5ff845330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#5 0x000078c5ff89eb2c __pthread_kill_implementation
#6 0x000078c5ff89eb2c __pthread_kill_internal
#7 0x000078c5ff89eb2c pthread_kill
#8 0x000078c5ff84527e raise
#9 0x000078c5ff8288ff abort
#10 0x000078c5ff82881b _nl_load_domain
#11 0x000078c5ff83b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#12 0x0000599ed8aa45b3 clang::SourceManager::getFileIDLoaded(unsigned int) const
#13 0x0000599ed8aa45b3 clang::SourceManager::getFileIDSlow(unsigned int) const
#14 0x0000599ed65e8a38 clang::SourceManager::getFileID(unsigned int) const
#15 0x0000599ed65e8a38 clang::SourceManager::getFileID(clang::SourceLocation) const
#16 0x0000599ed65e8a38 clang::SourceManager::getDecomposedLoc(clang::SourceLocation) const
#17 0x0000599ede8a948f clang::Rewriter::getLocationOffsetAndFileID(clang::SourceLocation, clang::FileID&) const
#18 0x0000599ede8a948f clang::Rewriter::ReplaceText(clang::SourceLocation, unsigned int, llvm::StringRef)
#19 0x0000599eda3bc353 clang::tooling::Replacement::apply(clang::Rewriter&) const
#20 0x0000599eda3cc0f3 clang::tooling::applyAllReplacements(llvm::StringRef, clang::tooling::Replacements const&)
#21 0x0000599eda3e1eef llvm::Expected::operator bool()
#22 0x0000599eda3e1eef clang::tooling::applyAtomicChanges(llvm::StringRef, llvm::StringRef,
llvm::ArrayRef, clang::tooling::ApplyChangesSpec const&)
#23 0x0000599ed625cbba ClangRefactorTool::applySourceChanges() (ClangRefactor.cpp:496)
#24 0x0000599ed625cbba main (ClangRefactor.cpp:643)
#25 0x000078c5ff82a1ca __libc_start_call_main
#26 0x000078c5ff82a28b call_init
#27 0x000078c5ff82a28b __libc_start_main
#28 0x0000599ed6186e75 _start
timeout: the monitored command dumped core
Aborted
```
Contributor guide
Research direction
Run the shown clang-refactor local-rename command against the provided test.cpp to reproduce the assertion. Read clang/lib/Basic/SourceManager.cpp around getFileIDLoaded and ClangRefactor.cpp around applySourceChanges; done means the valid C++ input no longer aborts during local-rename.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100