Skip to content

readability-else-after-return crashes #44090

@pgerell

Description

@pgerell
Bugzilla Link 44745
Resolution FIXED
Resolved on Feb 03, 2020 07:12
Version unspecified
OS Linux
Blocks #43900
CC @zmodem,@pgerell
Fixed by commit(s) d591bdc

Extended Description

clang-tidy-10 as of 2020-01-31 crashes when using readability-else-after-return on the following sample.

Command line used to reproduce:
$ clang-tidy test.cpp --checks='readability-else*' -- /usr/bin/clang++ -isystem boost_1_71_0/include test.cpp

==== test.cpp ======
#include
class Base {
};
#include "boost/range/irange.hpp"
std::unique_ptr makeBase() {
std::unique_ptr op;
if (auto* x = dynamic_cast<Base*>(op.get())) {
return op;
}
else if (auto* y = dynamic_cast<Base*>(op.get())) {
for (auto i : boost::irange(0, 4)) {
}
return op;
}
return op;
}

Expected behavior is a warning on line 10.
Actual behaviour is the following stack dump

================
Stack dump:
0. Program arguments: clang-tidy Instruction.cpp --checks=readability-else* -- /usr/bin/clang++ -isystem NPU1T-Tools-Linux-clang-10.0/build/external_boost/boost_x/include Instruction.cpp 1. parser at end of file
/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x1f)[0x7 fe3b2dcc72f]
/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1(_ZN4llvm3sys17RunSignalHandlersEv+0x50)[0x7fe3b2dca9f0] /usr/lib/x86_64-linux-gnu/libLLVM-10.so.1(+0x976cf5)[0x7fe3b2dcccf5]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12890)[0x7fe3b930c890]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang4Stmt8childrenEv+0xf)[0x7fe3b768f7cf]
clang-tidy[0x81911d]
clang-tidy[0x819180]
clang-tidy[0x819180]
clang-tidy[0x819180]
clang-tidy[0x817b08]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(+0xd1aa41)[0x7fe3b7859a41]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang12ast_matchers8internal21BoundNodesTreeBuilder12visitMatchesEPNS2_7VisitorE+0xcc)[0x7fe3b787400c]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(+0xd1a2bc)[0x7fe3b78592bc]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(+0xd34e49)[0x7fe3b7873e49]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(+0xd1c7e4)[0x7fe3b785b7e4]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(+0xd21937)[0x7fe3b7860937]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(+0xd1e65b)[0x7fe3b785d65b]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang12ast_matchers11MatchFinder8matchASTERNS_10ASTContextE+0x339)[0x7fe3b783f2e9]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang17MultiplexConsumer21HandleTranslationUnitERNS_10ASTContextE+0x2c)[0x7fe3b87f885c]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang8ParseASTERNS_4SemaEbb+0x283)[0x7fe3b730dca3]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang14FrontendAction7ExecuteEv+0x48)[0x7fe3b87c3d48]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang16CompilerInstance13ExecuteActionERNS_14FrontendActionE+0x601)[0x7fe3b877cd91]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang7tooling21FrontendActionFactory13runInvocationESt10shared_ptrINS_18CompilerInvocationEEPNS_11FileManagerES2_INS_22PCHContainerOperationsEEPNS_18DiagnosticConsumerE+0x19c)[0x7fe3b891758c]
clang-tidy[0x456316]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang7tooling14ToolInvocation13runInvocationEPKcPNS_6driver11CompilationESt10shared_ptrINS_18CompilerInvocationEES7_INS_22PCHContainerOperationsEE+0x106)[0x7fe3b89172f6]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang7tooling14ToolInvocation3runEv+0xa5a)[0x7fe3b891679a]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.10(_ZN5clang7tooling9ClangTool3runEPNS0_10ToolActionE+0xb8a)[0x7fe3b891898a]
clang-tidy[0x452ff7]
clang-tidy[0x450043]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x7fe3b1747b97]
clang-tidy[0x44e62a]
fish: 'clang-tidy Instruction.cpp --ch…' terminated by signal SIGSEGV (Address boundary error)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions