Closed anordal closed 3 weeks ago
@anordal Thanks for taking time to contribute to FreeRTOS+TCP. Enabling address and undefined behavior sanitizers in the CI check would help improve the code quality.
@anordal can you help fix the merge conflict with the test/unit-test/FreeRTOS_TCP_IP/FreeRTOS_TCP_IP_utest.c
?
Yes. I see you fixed a use after free (ba6ba81f). I'll push a rebase.
This PR adds an option to build with sanitizers, fixes all AddressSanitizer and UB-Sanitizer errors (because these sanitizers can be run together) and enforces them in CI.
Motivation: The tests were crashing when compiled with Gcc 13. With these fixes, they no longer do.
I think it would be nice for future development to run the tests with sanitizers in CI to prevent the sort of bugs I've now fixed. They were not few, which should contribute to reduce the amount of flakiness (especially crashiness) in the tests.
I have focused on what's necessary to enable these sanitizers, but there is more. Particularly uninitialized variables. The next I would do is ban it with
-Werror=maybe-uninitialized
, but that's going to reveal the rest of that iceberg.Test Matrix
cmake -DSANITIZE=address,undefined
andcmake -DSANITIZE=
.Checklist:
Related Issue
None.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.