From 87f6e83988b8208e6a1572d29a0866d5ea16f9e9 Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Tue, 2 Sep 2014 13:59:35 +0100 Subject: [PATCH] Add memory leak check #21 Runs unit tests via valgrind --- .gitignore | 1 + tests/leak.sh | 7 +++ tests/sharp.supp | 111 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100755 tests/leak.sh create mode 100644 tests/sharp.supp diff --git a/.gitignore b/.gitignore index 73142c35..e11f88cf 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ results build node_modules tests/fixtures/output.* +tests/libvips.supp diff --git a/tests/leak.sh b/tests/leak.sh new file mode 100755 index 00000000..0ba05714 --- /dev/null +++ b/tests/leak.sh @@ -0,0 +1,7 @@ +if ! type valgrind >/dev/null; then + echo "Please install valgrind before running memory leak tests" + exit 1 +fi + +curl -O https://raw.githubusercontent.com/jcupitt/libvips/master/libvips.supp +G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind --suppressions=libvips.supp --suppressions=sharp.supp --leak-check=full --show-leak-kinds=definite,indirect,possible node unit.js diff --git a/tests/sharp.supp b/tests/sharp.supp new file mode 100644 index 00000000..549190c3 --- /dev/null +++ b/tests/sharp.supp @@ -0,0 +1,111 @@ +# libjpeg warnings +{ + cond_jpeg_read_scanlines + Memcheck:Cond + ... + fun:jpeg_read_scanlines +} +{ + value_jpeg_read_scanlines + Memcheck:Value8 + ... + fun:jpeg_read_scanlines +} +{ + cond_jpeg_write_scanlines + Memcheck:Cond + ... + fun:jpeg_write_scanlines +} +{ + cond_jpeg_finish_compress + Memcheck:Cond + ... + fun:jpeg_finish_compress +} +{ + value_jpeg_finish_compress + Memcheck:Value8 + ... + fun:jpeg_finish_compress +} + +# libvips interpolator warnings +{ + cond_libvips_interpolate_lbb + Memcheck:Cond + ... + fun:_ZL32vips_interpolate_lbb_interpolateP16_VipsInterpolatePvP11_VipsRegiondd + fun:vips_affine_gen +} + +# libuv warnings +{ + free_libuv + Memcheck:Free + ... + fun:uv__work_done +} + +# nodejs warnings +{ + param_nodejs_write_buffer + Memcheck:Param + write(buf) + ... + obj:/usr/bin/nodejs +} +{ + leak_nodejs_ImmutableAsciiSource_CreateFromLiteral + Memcheck:Leak + match-leak-kinds: definite + ... + fun:_ZN4node20ImmutableAsciiSource17CreateFromLiteralEPKcm +} +{ + leak_nodejs_Buffer_New + Memcheck:Leak + match-leak-kinds: definite + ... + fun:_ZN4node6Buffer3NewERKN2v89ArgumentsE +} +{ + leak_nodejs_Buffer_Replace + Memcheck:Leak + match-leak-kinds: indirect,possible + ... + fun:_ZN4node6Buffer7ReplaceEPcmPFvS1_PvES2_ +} +{ + leak_nodejs_SignalWrap_New + Memcheck:Leak + match-leak-kinds: possible + ... + fun:_ZN4node10SignalWrap3NewERKN2v89ArgumentsE +} +{ + leak_nodejs_TTYWrap_New + Memcheck:Leak + match-leak-kinds: possible + ... + fun:_ZN4node7TTYWrap3NewERKN2v89ArgumentsE +} +{ + leak_nodejs_ares_init_options + Memcheck:Leak + match-leak-kinds: reachable + fun:malloc + fun:strdup + ... + fun:ares_init_options +} + +# vips__init warnings +{ + leak_libvips_init + Memcheck:Leak + match-leak-kinds: reachable + fun:malloc + ... + fun:vips__init +}