Skip to content

Commit

Permalink
fixed fuzzing crash
Browse files Browse the repository at this point in the history
AddressSanitizer:DEADLYSIGNAL
=================================================================
==247105==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000040 (pc 0x55dd2f3cde37 bp 0x7ffcb1f26ad0 sp 0x7ffcb1f269a0 T0)
==247105==The signal is caused by a READ memory access.
==247105==Hint: address points to the zero page.
    #0 0x55dd2f3cde37 in Token::variable() const /home/user/CLionProjects/cppcheck-rider/oss-fuzz/../lib/token.h:1082:16
    #1 0x55dd2f3cde37 in CheckUninitVar::isVariableUsage(Token const*, Library const&, bool, CheckUninitVar::Alloc, int) /home/user/CLionProjects/cppcheck-rider/oss-fuzz/../lib/checkuninitvar.cpp:1290:42
    #2 0x55dd2f3c9322 in CheckUninitVar::isVariableUsage(Token const*, bool, CheckUninitVar::Alloc, int) const /home/user/CLionProjects/cppcheck-rider/oss-fuzz/../lib/checkuninitvar.cpp:1343:12
    #3 0x55dd2f3c9322 in CheckUninitVar::checkLoopBodyRecursive(Token const*, Variable const&, CheckUninitVar::Alloc, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, bool&) const /home/user/CLionProjects/cppcheck-rider/oss-fuzz/../lib/checkuninitvar.cpp:1037:39
    #4 0x55dd2f3b5995 in CheckUninitVar::checkLoopBody(Token const*, Variable const&, CheckUninitVar::Alloc, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, bool) /home/user/CLionProjects/cppcheck-rider/oss-fuzz/../lib/checkuninitvar.cpp:1072:31
    #5 0x55dd2f3bbf99 in CheckUninitVar::checkScopeForVariable(Token const*, Variable const&, bool*, bool*, CheckUninitVar::Alloc*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::map<int, VariableValue, std::less<int>, std::allocator<std::pair<int const, VariableValue>>>&) /home/user/CLionProjects/cppcheck-rider/oss-fuzz/../lib/checkuninitvar.cpp:637:35
    #6 0x55dd2f3b3850 in CheckUninitVar::checkScope(Scope const*, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&) /home/user/CLionProjects/cppcheck-rider/oss-fuzz/../lib/checkuninitvar.cpp:201:17
    #7 0x55dd2f3b258a in CheckUninitVar::check() /home/user/CLionProjects/cppcheck-rider/oss-fuzz/../lib/checkuninitvar.cpp:131:13
    #8 0x55dd2f3d9d64 in CheckUninitVar::runChecks(Tokenizer const&, ErrorLogger*) /home/user/CLionProjects/cppcheck-rider/oss-fuzz/../lib/checkuninitvar.h:86:24
    #9 0x55dd2f485834 in CppCheck::checkNormalTokens(Tokenizer const&) /home/user/CLionProjects/cppcheck-rider/oss-fuzz/../lib/cppcheck.cpp:1103:20
    #10 0x55dd2f499c5d in CppCheck::checkFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::istream*) /home/user/CLionProjects/cppcheck-rider/oss-fuzz/../lib/cppcheck.cpp:936:17
    #11 0x55dd2f4a5521 in CppCheck::check(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) /home/user/CLionProjects/cppcheck-rider/oss-fuzz/../lib/cppcheck.cpp:558:12
    #12 0x55dd2eeaed03 in LLVMFuzzerTestOneInput /home/user/CLionProjects/cppcheck-rider/oss-fuzz/main.cpp:45:18
    #13 0x55dd2ed55538 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/home/user/CLionProjects/cppcheck-rider/oss-fuzz/oss-fuzz-client+0x573538) (BuildId: a183bbe392f62ddef4ec71808dcbc702acf3775d)
    #14 0x55dd2ed56210 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) (/home/user/CLionProjects/cppcheck-rider/oss-fuzz/oss-fuzz-client+0x574210) (BuildId: a183bbe392f62ddef4ec71808dcbc702acf3775d)
    #15 0x55dd2ed572a1 in fuzzer::Fuzzer::MutateAndTestOne() (/home/user/CLionProjects/cppcheck-rider/oss-fuzz/oss-fuzz-client+0x5752a1) (BuildId: a183bbe392f62ddef4ec71808dcbc702acf3775d)
    #16 0x55dd2ed580c7 in fuzzer::Fuzzer::Loop(std::vector<fuzzer::SizedFile, std::allocator<fuzzer::SizedFile>>&) (/home/user/CLionProjects/cppcheck-rider/oss-fuzz/oss-fuzz-client+0x5760c7) (BuildId: a183bbe392f62ddef4ec71808dcbc702acf3775d)
    #17 0x55dd2ed385b2 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/home/user/CLionProjects/cppcheck-rider/oss-fuzz/oss-fuzz-client+0x5565b2) (BuildId: a183bbe392f62ddef4ec71808dcbc702acf3775d)
    #18 0x55dd2ecbcfa7 in main (/home/user/CLionProjects/cppcheck-rider/oss-fuzz/oss-fuzz-client+0x4dafa7) (BuildId: a183bbe392f62ddef4ec71808dcbc702acf3775d)
    #19 0x7f09f9558ccf  (/usr/lib/libc.so.6+0x27ccf) (BuildId: 8bfe03f6bf9b6a6e2591babd0bbc266837d8f658)
    #20 0x7f09f9558d89 in __libc_start_main (/usr/lib/libc.so.6+0x27d89) (BuildId: 8bfe03f6bf9b6a6e2591babd0bbc266837d8f658)
    #21 0x55dd2ed22354 in _start (/home/user/CLionProjects/cppcheck-rider/oss-fuzz/oss-fuzz-client+0x540354) (BuildId: a183bbe392f62ddef4ec71808dcbc702acf3775d)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/user/CLionProjects/cppcheck-rider/oss-fuzz/../lib/token.h:1082:16 in Token::variable() const
==247105==ABORTING
  • Loading branch information
firewave committed Feb 14, 2024
1 parent 795d538 commit c36e172
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/checkuninitvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@ const Token* CheckUninitVar::isVariableUsage(const Token *vartok, const Library&
if (Token::Match((derefValue ? derefValue : vartok)->astParent(), "(|=") && astIsRhs(derefValue ? derefValue : vartok)) {
const Token *rhstok = derefValue ? derefValue : vartok;
const Token *lhstok = rhstok->astParent()->astOperand1();
const Variable *lhsvar = lhstok->variable();
const Variable *lhsvar = lhstok ? lhstok->variable() : nullptr;
if (lhsvar && lhsvar->isReference() && lhsvar->nameToken() == lhstok)
return nullptr;
}
Expand Down
Binary file not shown.

0 comments on commit c36e172

Please sign in to comment.