This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Fix bugprone-bad-signal-to-kill-thread crash when `SIGTERM` is not a literal.
ClosedPublic

Authored by ArcsinX on Aug 5 2020, 11:39 PM.

Details

Summary

If SIGTERM is not a literal (e.g. #define SIGTERM ((unsigned)15)) bugprone-bad-signal-to-kill-thread check crashes.
Stack dump:

#0 0x000000000217d15a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/llvm-project/build/bin/clang-tidy+0x217d15a)
#1 0x000000000217b17c llvm::sys::RunSignalHandlers() (/llvm-project/build/bin/clang-tidy+0x217b17c)
#2 0x000000000217b2e3 SignalHandler(int) (/llvm-project/build/bin/clang-tidy+0x217b2e3)
#3 0x00007f6a7efb1390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#4 0x000000000212ac9b llvm::StringRef::getAsInteger(unsigned int, llvm::APInt&) const (/llvm-project/build/bin/clang-tidy+0x212ac9b)
#5 0x0000000000593501 clang::tidy::bugprone::BadSignalToKillThreadCheck::check(clang::ast_matchers::MatchFinder::MatchResult const&) (/llvm-project/build/bin/clang-tidy+0x593501)

Diff Detail

Event Timeline

ArcsinX created this revision.Aug 5 2020, 11:39 PM
ArcsinX requested review of this revision.Aug 5 2020, 11:39 PM
ArcsinX added a project: Restricted Project.
hokein accepted this revision.Aug 6 2020, 12:09 AM
hokein added inline comments.
clang-tools-extra/test/clang-tidy/checkers/bugprone-bad-signal-to-kill-thread-sigterm-not-a-literal.cpp
1

the same here.

This revision is now accepted and ready to land.Aug 6 2020, 12:09 AM
ArcsinX updated this revision to Diff 283509.Aug 6 2020, 12:23 AM

Fix test according to review comment

Thank you for review!

clang-tools-extra/test/clang-tidy/checkers/bugprone-bad-signal-to-kill-thread-sigterm-not-a-literal.cpp
1

Fixed