X Tutup
Skip to content

fix a large number of valgrind warnings in testrunner#2920

Merged
danmar merged 1 commit intodanmar:mainfrom
IOBYTE:valgrind
Nov 24, 2020
Merged

fix a large number of valgrind warnings in testrunner#2920
danmar merged 1 commit intodanmar:mainfrom
IOBYTE:valgrind

Conversation

@IOBYTE
Copy link
Copy Markdown
Contributor

@IOBYTE IOBYTE commented Nov 24, 2020

==28830== Conditional jump or move depends on uninitialised value(s)
==28830== at 0x10252E4: valueFlowLifetime(TokenList*, SymbolDatabase*, ErrorLogger*, Settings const*)::{lambda(Token const*, Lambda::Capture, std::function<bool (Token const*)>)#2}::operator()(Token const*, Lambda::Capture, std::function<bool (Token const*)>) const (valueflow.cpp:3656)
==28830== by 0x1025A03: valueFlowLifetime(TokenList*, SymbolDatabase*, ErrorLogger*, Settings const*) (valueflow.cpp:3685)
==28830== by 0x1038E94: ValueFlow::setValues(TokenList*, SymbolDatabase*, ErrorLogger*, Settings const*) (valueflow.cpp:6569)
==28830== by 0xF8D155: Tokenizer::simplifyTokens1(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) (tokenize.cpp:2384)
==28830== by 0xF8D390: Tokenizer::tokenize(std::istream&, char const*, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) (tokenize.cpp:2401)
==28830== by 0x80918B: TestAssert::check(char const*, char const*) (testassert.cpp:40)
==28830== by 0x809F6D: TestAssert::assignmentInAssert() (testassert.cpp:231)
==28830== by 0x809386: TestAssert::run() (testassert.cpp:50)
==28830== by 0xA99ED7: TestFixture::run(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) (testsuite.cpp:309)
==28830== by 0xA9A1FA: TestFixture::runTests(options const&) (testsuite.cpp:332)
==28830== by 0x9EDEC9: main (testrunner.cpp:44)

@danmar
Copy link
Copy Markdown
Owner

danmar commented Nov 24, 2020

hmm.. it would have been very good to detect this.

@danmar danmar merged commit 43ce160 into danmar:main Nov 24, 2020
@danmar
Copy link
Copy Markdown
Owner

danmar commented Nov 24, 2020

I believe we should try to create a small testcase that cppcheck does not warn about.. and create a ticket.

@danmar
Copy link
Copy Markdown
Owner

danmar commented Nov 24, 2020

I created https://trac.cppcheck.net/ticket/10009

I do not think it would be possible to write conclusive warnings about such bugs in Cppcheck. I do not know; maybe an inconclusive warning might be ok if there is a "theoretical" execution path in the constructor that does not initialize the member. Otherwise we could in the long run warn about it in the bug hunting analysis.

@orbitcowboy
Copy link
Copy Markdown
Collaborator

Since valgrind is able to detect this issue, we could reactivate our valgrind CI check.

@amai2012
Copy link
Copy Markdown
Collaborator

Hmm, asan/ubsan did not detect this??

@rikardfalkeborn
Copy link
Copy Markdown
Contributor

Hmm, asan/ubsan did not detect this??

asan only detects reads/writes outside of memory, not reading uninitialized memory so that is expected. For uninitialized memory, there is msan (https://clang.llvm.org/docs/MemorySanitizer.html). I've never used it but it seems there may be false positives if not all linked libs are compiled with msan as well, but perhaps it's worth trying to add it to CI?

@amai2012 amai2012 mentioned this pull request Nov 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

X Tutup