gdal icon indicating copy to clipboard operation
gdal copied to clipboard

add valgrind on tests in ci and fix all the leaks

Open jdroenner opened this issue 3 years ago • 5 comments

run valgrind with:

CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="valgrind --num-callers=100 --track-origins=yes --leak-check=full --time-stamp=yes" cargo test

current report is attached rustgdal_valgrind.txt

The "Syscall param statx(file_name) points to unaddressable byte(s)" message is not a real error.

jdroenner avatar Aug 03 '21 14:08 jdroenner

In my opinion, it is good to run Valgrind since we deal with lots of unsafe code here. This would also prevent you from doing these kinds of clean-ups every now and then.

ChristianBeilschmidt avatar Oct 18 '21 20:10 ChristianBeilschmidt

FWIW, valgrind never finishes for me, but LSAN and ASAN don't complain about anything. Tested using:

TRYBUILD=overwrite RUSTFLAGS="-Z sanitizer=leak -C linker=clang" RUSTDOCFLAGS="-Z sanitizer=leak -C linker=clang" cargo +nightly test --target x86_64-unknown-linux-gnu --release

If I comment out the CSLDestroy in CslStringList, it does report a leak.

PS: trybuild is annoying and I'm not sure it's pulling its weight in compile time and potential for breakage. Currently it complains about a change in the error message in nightly.

lnicola avatar Oct 19 '21 15:10 lnicola

I saw that ASAN was already discussed here: https://github.com/georust/gdal/issues/165

I guess it is nicer than valgrind for our use case, but comes with the nightly issue. From my experience, we would have to fix a nightly because it will definitely crash for some nightlies. In our Geo Engine project, we have a CI task that updates the nightly version from time to time :shrug:.

Why is trybuild necessary, since it isn't part of https://github.com/georust/gdal/pull/167/files as far as I see?

ChristianBeilschmidt avatar Oct 20 '21 16:10 ChristianBeilschmidt

Why is trybuild necessary, since it isn't part of https://github.com/georust/gdal/pull/167/files as far as I see?

To check that a layer's features borrow the layer, see the single test in https://github.com/georust/gdal/tree/master/tests/compile-tests.

I guess it is nicer than valgrind for our use case, but comes with the nightly issue.

Behold (but don't tell the rustc people I suggested this):

__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS=stable RUSTC_BOOTSTRAP=1 RUSTFLAGS="-Z sanitizer=leak -C linker=clang" RUSTDOCFLAGS="-Z sanitizer=leak -C linker=clang" cargo test --target x86_64-unknown-linux-gnu --release

lnicola avatar Oct 21 '21 13:10 lnicola

Not sure if it's as comprehensive as valgrind, but this has been added, which includes ASAN:

https://github.com/georust/gdal/pull/398?

metasim avatar May 22 '23 19:05 metasim