Add autotest option to run unit tests under asan / run them in CI / fix bugs foud - #33976
Add autotest option to run unit tests under asan / run them in CI / fix bugs foud#33976peterbarker wants to merge 5 commits into
Conversation
…ing test The test explicitly called the destructor and then read the freed buffer, and filled a 2048 byte array with 'a' with no terminator before passing it to printf. Both are found by address sanitizer. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The AP_Param constructor scans the table for AP_PARAM_NONE to count the parameters, so an unterminated table is read past the end. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The index was advanced before the last two checks, so they tested the following result and read past the end of the table on the final call. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ArduPilot does not free its singletons, so leak checking reports a great deal which is not a bug. Tests which do not otherwise pull in AP_Common/c++.cpp get operator new from the ASAN runtime rather than our own calloc based one, so fill allocations with zero to match. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Adds a unit-tests-asan configuration which builds and runs the unit tests with --asan. Only clang is used as boards.py adds the sanitizer link flag for clang alone, and --asan is only implemented for the sitl board so the linux unit tests remain uninstrumented. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
khancyr
left a comment
There was a problem hiding this comment.
looks like we don't have libclang-rt-18-dev on the container ...
do you prefer I update the container and we keep the same tag, or I create another tag and we change the tag version on the CI workflow ?
| sitl | ||
| ] | ||
| exclude: | ||
| # boards.py only adds the sanitizer link flag when building |
There was a problem hiding this comment.
should we add support for asan on gcc ? from the docs it should be supported
Maybe we should just take the test fixes for now? I mean, 4 errors in all of the tests over how many years - and the errors were only in the tests. So I think I should just archive the asan thing for later.... |
|
well, did you try to run on some SITL test ? our unittests are far from covering significant part of the codebase. |
Summary
Fixes bugs found by running the unit tests under asan
Classification & Testing (check all that apply and add your own)
Description
Adds infrastructure to run unit tests under asan and fixes bugs found...