From 2cf38f8e1c1d3b50ac41b002308de5eea9efc61d Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sun, 22 Sep 2019 19:44:00 -0300 Subject: [PATCH 1/3] test: known broken test file descriptor leak in gzip file open James Troup reported this bug in id:87pnjsf9q5.fsf@canonical.com --- test/T750-gzip.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/T750-gzip.sh b/test/T750-gzip.sh index 5b678fa1..f4e0c42a 100755 --- a/test/T750-gzip.sh +++ b/test/T750-gzip.sh @@ -167,4 +167,12 @@ This is just a test message (#7) EOF test_expect_equal_file EXPECTED OUTPUT +# there are more than 200 messages in this corpus +add_email_corpus lkml +test_begin_subtest "new doesn't run out of file descriptors with many gzipped files" +test_subtest_known_broken +ulimit -n 200 +gzip --recursive ${MAIL_DIR} +test_expect_success "notmuch new" + test_done From 4c5b17b10b786994255641fee8df4733c3586f3e Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sun, 22 Sep 2019 19:44:01 -0300 Subject: [PATCH 2/3] util: unreference objects referenced by the returned stream obj We want freeing the returned stream to also free these underlying objects. Compare tests/test-filters.c in the gmime 3.2.x source, which uses this same idiom. Thanks to James Troup for the report and the fix. --- test/T750-gzip.sh | 1 - util/gmime-extra.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test/T750-gzip.sh b/test/T750-gzip.sh index f4e0c42a..fac41d39 100755 --- a/test/T750-gzip.sh +++ b/test/T750-gzip.sh @@ -170,7 +170,6 @@ test_expect_equal_file EXPECTED OUTPUT # there are more than 200 messages in this corpus add_email_corpus lkml test_begin_subtest "new doesn't run out of file descriptors with many gzipped files" -test_subtest_known_broken ulimit -n 200 gzip --recursive ${MAIL_DIR} test_expect_success "notmuch new" diff --git a/util/gmime-extra.c b/util/gmime-extra.c index 7562d906..4a591cae 100644 --- a/util/gmime-extra.c +++ b/util/gmime-extra.c @@ -28,6 +28,8 @@ _gzfile_maybe_filter (GMimeStream *file_stream) { /* ignore filter id */ (void)g_mime_stream_filter_add ((GMimeStreamFilter *)gzstream, gzfilter); + g_object_unref(gzfilter); + g_object_unref(file_stream); return gzstream; } else { return file_stream; From 49621ea8d5596e707d81ec5aafcfb6a19f864819 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sun, 13 Oct 2019 09:18:24 -0300 Subject: [PATCH 3/3] util: whitespace cleanup for 4c5b17b1 Oops. This should make the merge back to master smoother. --- util/gmime-extra.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util/gmime-extra.c b/util/gmime-extra.c index 4a591cae..d1bb1d47 100644 --- a/util/gmime-extra.c +++ b/util/gmime-extra.c @@ -27,9 +27,9 @@ _gzfile_maybe_filter (GMimeStream *file_stream) { return NULL; /* ignore filter id */ - (void)g_mime_stream_filter_add ((GMimeStreamFilter *)gzstream, gzfilter); - g_object_unref(gzfilter); - g_object_unref(file_stream); + (void) g_mime_stream_filter_add ((GMimeStreamFilter *) gzstream, gzfilter); + g_object_unref (gzfilter); + g_object_unref (file_stream); return gzstream; } else { return file_stream;