TopoToolbox / libtopotoolbox

A C library for the analysis of digital elevation models.
https://topotoolbox.github.io/libtopotoolbox/
GNU General Public License v3.0
0 stars 5 forks source link

Provide an option to build tests with AddressSanitizer #60

Closed wkearn closed 3 months ago

wkearn commented 3 months ago

Fixes #59

AddressSanitizer instruments our code at run time to detect certain kinds of memory errors. It is useful to have around for testing. The -DTT_SANITIZE option can be passed to cmake to enable the sanitizer in Debug builds when using clang and gcc. It is possible to use AddressSanitizer with MSVC as well, but it requires some more complicated linking strategies.

This PR also sets the TT_SANITIZE flag on GitHub Actions when running on Ubuntu with Clang in Debug mode.

AddressSanitizer already caught some memory leaks caused by not cleaning up allocations in some of the test functions. Those have also been fixed in this PR to ensure that CI succeeds.