From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 04E92429E25 for ; Sat, 31 Dec 2011 19:23:00 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -2.3 X-Spam-Level: X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mCla+WkzyUAs for ; Sat, 31 Dec 2011 19:22:58 -0800 (PST) Received: from tempo.its.unb.ca (tempo.its.unb.ca [131.202.1.21]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 07751431FB6 for ; Sat, 31 Dec 2011 19:22:57 -0800 (PST) Received: from zancas.localnet (fctnnbsc36w-156034079193.pppoe-dynamic.High-Speed.nb.bellaliant.net [156.34.79.193]) (authenticated bits=0) by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id q013Mrsm017592 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Sat, 31 Dec 2011 23:22:54 -0400 Received: from bremner by zancas.localnet with local (Exim 4.77) (envelope-from ) id 1RhC0b-0002DA-56; Sat, 31 Dec 2011 23:22:53 -0400 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH v2 3/3] lib: call g_mime_init() from notmuch_database_open() Date: Sat, 31 Dec 2011 23:22:49 -0400 Message-Id: <1325388169-8444-4-git-send-email-david@tethera.net> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1325388169-8444-1-git-send-email-david@tethera.net> References: <1325306261-21444-2-git-send-email-kaz.rag@gmail.com> <1325388169-8444-1-git-send-email-david@tethera.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Jan 2012 03:23:00 -0000 From: Kazuo Teramoto As reported in id:"CAEbOPGyuHnz4BPtDutnTPUHcP3eYcRCRkXhYoJR43RUMw671+g@mail.gmail.com" sometimes gmime tries to access a NULL pointer, e.g. g_mime_iconv_open() tries to access iconv_cache that is NULL if g_mime_init() is not called. This causes notmuch to segfault when calling gmime functions. Calling g_mime_init() initializes iconv_cache and others variables needed by gmime, making sure they are initialized when notmuch calls gmime functions. Test marked fix by db. --- lib/database.cc | 9 +++++++++ test/python | 1 - 2 files changed, 9 insertions(+), 1 deletions(-) diff --git a/lib/database.cc b/lib/database.cc index d11dfaf..8103bd9 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -28,6 +28,8 @@ #include /* g_free, GPtrArray, GHashTable */ #include /* g_type_init */ +#include /* g_mime_init */ + using namespace std; #define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0])) @@ -585,6 +587,7 @@ notmuch_database_open (const char *path, struct stat st; int err; unsigned int i, version; + static int initialized = 0; if (asprintf (¬much_path, "%s/%s", path, ".notmuch") == -1) { notmuch_path = NULL; @@ -608,6 +611,12 @@ notmuch_database_open (const char *path, /* Initialize the GLib type system and threads */ g_type_init (); + /* Initialize gmime */ + if (! initialized) { + g_mime_init (0); + initialized = 1; + } + notmuch = talloc (NULL, notmuch_database_t); notmuch->exception_reported = FALSE; notmuch->path = talloc_strdup (notmuch, path); diff --git a/test/python b/test/python index 0b56db3..c3aa726 100755 --- a/test/python +++ b/test/python @@ -5,7 +5,6 @@ test_description="python bindings" add_email_corpus test_begin_subtest "compare thread ids" -test_subtest_known_broken test_python <