From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 0OJxMBCOc2GZAAEAgWs5BA (envelope-from ) for ; Sat, 23 Oct 2021 06:22:40 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id sG8nLBCOc2H3CAAAB5/wlQ (envelope-from ) for ; Sat, 23 Oct 2021 04:22:40 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 41431D726 for ; Sat, 23 Oct 2021 06:22:40 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 3DD2B2902E; Sat, 23 Oct 2021 00:22:34 -0400 (EDT) Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by mail.notmuchmail.org (Postfix) with ESMTPS id 8912026F0B for ; Sat, 23 Oct 2021 00:22:28 -0400 (EDT) Received: by mail-qt1-x82b.google.com with SMTP id z24so5362959qtv.9 for ; Fri, 22 Oct 2021 21:22:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=austinray-io.20210112.gappssmtp.com; s=20210112; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=webyyn2zSw+r8u4CrS+E8I69xWXa9lB3qM4VmQQgPCg=; b=2knewMsJrJz/EvlG58ctFMDvFq6mvJzpeY0LXKfoH1ZRall3RBAxw1TnHLv0ksGSmc mfV6DTU/GXbSiiKz6r8qHzhHNeoo3HG/iNqzUKGUttJUECUJhJ3d+gHjwwInWHNOOkdC UgSqje3QLeW3Cdy6P2VlgRhyGG5+KzuFzZ6dhdL0qQX2e5omlNTsRP0Q1ShnfDOt1+TF 3EX6YMZDkiGeUNy+e6iK3c1uvp/U779/D2jids0MAvZhn4AHpTNkJpcXak8bZ7mj6hfk Y5NDn7wphF0OkePfAVfwO8y/IkhGNDL4U4YkhVn64dk1NOatsL19vscXqs0QMCedVHRJ ihqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=webyyn2zSw+r8u4CrS+E8I69xWXa9lB3qM4VmQQgPCg=; b=I+Tg/VReg6qZAqyOLFICOTwChpEUng0RNukJXAn7wuk1rzm1LsRt5DJGv8B6DU3+qJ MfzZ2q54/M1ENucapWnECeaFMtYITYIRlT8VetFofb4gdajVbHRR/tZ81T0P1aPsEUzs sWeiyF5IMmmGsJs41JuBd12QyXfW3WoMzKQrXxiWpNkBJ5EQb5bUT8sbPEM21XMStmUa FytY43vHyi5nlGMfvu3sAjwpTKmP4D99F1xG+EbJ5jyR8nJpZOVIb3N8kU5B8H6PHrXJ 7XEAe6LLh1rFdWwE7MLkcLqPb5nHw8059AKhz3eQR932xuiFX/Knyse6vgLXmgDnEN+l 6WeQ== X-Gm-Message-State: AOAM531Xo5qALSlo4mIvhUG70ueSu2UskyCjWSOxFaunpHo62RKyX54k B1sU0lA7bvdFFt2uqAEcU+z60VjVzNXc3g== X-Google-Smtp-Source: ABdhPJxRXM6YBN15zWZ636z61kyVBhBnFQ7rnaLgRGiglkStH8K5Oz/gnc2aQs7WBPK/THWhuvSmtg== X-Received: by 2002:ac8:42dd:: with SMTP id g29mr4277306qtm.168.1634962947223; Fri, 22 Oct 2021 21:22:27 -0700 (PDT) Received: from localhost (68-20-11-88.lightspeed.rlghnc.sbcglobal.net. [68.20.11.88]) by smtp.gmail.com with ESMTPSA id h19sm5313245qtb.18.2021.10.22.21.22.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Oct 2021 21:22:26 -0700 (PDT) Date: Sat, 23 Oct 2021 00:22:25 -0400 From: Austin Ray To: notmuch@notmuchmail.org Subject: Re: notmuch_database_open_with_config() does not NULL pointer on error Message-ID: <20211023042225.xt36nzpsukqs6kid@athena> References: <20211021190401.imirxau2ewke6e2m@athena> MIME-Version: 1.0 In-Reply-To: <20211021190401.imirxau2ewke6e2m@athena> Message-ID-Hash: ZXUWVS5VUOA3GYR4MOPYL44EEX24AKFX X-Message-ID-Hash: ZXUWVS5VUOA3GYR4MOPYL44EEX24AKFX X-MailFrom: austin@austinray.io X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: multipart/mixed; boundary="===============1816320438361982816==" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1634962960; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=2Ign8asOJRLdJ2edunkjW2ito7JAorlYxAc54LEd2/M=; b=dlJCXmDt1fq0DXbaP/bTjhl/G43SWrFXZM/hORh+XJO1lTPC2hHzfmMJSBp83iwo/SveGi MyPKk/tBwEJfiC8SEQ00KRha72BIJi5dcGAGsTumlb5VlBFKfjRd9eWw57Ijp2UTsjt/tp mmmmcjwhF5ou2mj9+9qUTFlM4yca7Shw/oYEF3gR0Jg0XVrYTeWWiMhPwhB4Y2B4e8RQ80 v6vEJF2q+UYgA76igSIZHt+Qf0Y7E2lCSY6kMjSXrZqTuhpOWIWqmS90ul+Z4fM9rLtgC0 Q3Ni/tlRZVrCtgB5ZzU3U/cdI2hg73JT2FclsAaiaS3cwIT1NMA1XWFNdOMJmg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1634962960; a=rsa-sha256; cv=none; b=LVV67xUqtrCWHMyNeeYXX98q7ZVqwKAZj1xdOY53udnjNqD+OyDh4TSiEmDDd/QpZqCode s6eKAaGqys7hOAG6UcDVFB4El9jI22qXbCluPbTpA9+F+UN9rqiCiWTSKxcsSt8jwqTs1l H58Pawn+TqZ42wqCEvttxrG0mGMPBBD+2RVLM3DwC+kjXYcfINuFJAS9masEHRRErdnxbt TXXcHMnzhN9eM2usUxDX8T5AZcyunwRTveLZ7edbDDTHUnhMw4ap/w7R+oIrf78MOFMDVv SUl91I4h6aHIPf3F0McQQK3LsXpZxGkxvNrdFn1J53aBakZQF6aYlnOvF5TWqg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=austinray-io.20210112.gappssmtp.com header.s=20210112 header.b=2knewMsJ; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -2.75 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=austinray-io.20210112.gappssmtp.com header.s=20210112 header.b=2knewMsJ; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 41431D726 X-Spam-Score: -2.75 X-Migadu-Scanner: scn0.migadu.com X-TUID: cjczFUa94cx+ --===============1816320438361982816== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="qk5xigjbzk3b2g2l" Content-Disposition: inline --qk5xigjbzk3b2g2l Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Following up on this, ASAN reports a memory leak on a failure. Using 'notmuch_database_close()' or 'notmuch_database_destroy()' results in a SEGFAULT. I've updated my reproducer program to free the database on non-failure cases so it's easier to see the memory leak. #include #include int main() { const char *db_path =3D "/home/aray/mail"; notmuch_database_t *db =3D NULL; notmuch_status_t st =3D notmuch_database_open_with_config( db_path, NOTMUCH_DATABASE_MODE_READ_ONLY, NULL, NULL, &db, NULL); if (st !=3D NOTMUCH_STATUS_SUCCESS) { printf("Received status: %s\n", notmuch_status_to_string(st)); if (db) { printf("Received non-null DB pointer\n"); return -1; } } if (db) { notmuch_database_destroy(db); } return 0; } If there's an obvious way to fix the memory leak that I may have overlooked, please let me know. I'm not a C expert. Thanks, Austin --=20 https://austinray.io Open Source Maintainer, Software Engineer, Keyboard Enthusiast GPG: 0127 ED83 B939 CCC9 8082 476E 1AA0 B115 C8AC 2C9E --qk5xigjbzk3b2g2l Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQTaYk66K9eIYbyUx+6J1sK5lQPcSQUCYXON/AAKCRCJ1sK5lQPc SVFLAQDG1Bsi6fVA0yShMSxX3fHcFdye9957yMUkTaILsG3QWgD/bnW2nofZe7y8 a+zLUAiBsG95KG5GMF59dKyO/laHkwo= =WppF -----END PGP SIGNATURE----- --qk5xigjbzk3b2g2l-- --===============1816320438361982816== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============1816320438361982816==--