From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 6GVeOpwf1mE7MQEAgWs5BA (envelope-from ) for ; Wed, 05 Jan 2022 23:45:48 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id +JIKM5wf1mH2IwEAG6o9tA (envelope-from ) for ; Wed, 05 Jan 2022 23:45:48 +0100 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (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 951262FF54 for ; Wed, 5 Jan 2022 23:45:48 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id D79AD5F708; Wed, 5 Jan 2022 22:45:43 +0000 (UTC) Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by mail.notmuchmail.org (Postfix) with ESMTPS id 7B7575F6C5 for ; Wed, 5 Jan 2022 22:45:41 +0000 (UTC) Received: by mail-qt1-x82e.google.com with SMTP id s19so530156qtc.5 for ; Wed, 05 Jan 2022 14:45:41 -0800 (PST) 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:mime-version:content-disposition; bh=Q2QhEBVX6+6detKMAzloZyL5GqQMIZawrvBUVajIZQM=; b=wdTnYjHs4t1OCoxjNXgiaY+LiRGxJUuhhGB4pD1BnJ1uv7N/HJ3WIDe0jxH9tHCDIq sSzMHRyXKzCPWZ5GAECOKv/fde495Tej3og/6/ebN04BO88UkvLFtN/znINgRsuIN9lh xu+9yjTal/+5IfqSTrRx389vGfyEZj3xkmeS7sZEkQFbgje8EX/ciW6yDpzgDzvLEi6/ HB2VbA+17MWlTz7E6rLXh57ecmtVUmd3mj56wZRBjpD7BWJ1Q9iQmahMJEj3zcjr00SG hBzYwpi2qH/qcKiJS0k4OKDvbGtvZFXjTShVONzXHkALOUHD+H2PBTmD5CuKsuBiI7/4 nSbg== 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:mime-version :content-disposition; bh=Q2QhEBVX6+6detKMAzloZyL5GqQMIZawrvBUVajIZQM=; b=FaXKAFhJ+r2SFoQ5SryEGh+CFiryjFTpXC8SnXqwkEUlbZCSp1HDLcCgw/lG3/tobd FOzJTe24rsWSJVa1nftrCJVWgi6bXvCbiTCsgl0Q0AayB+9SwBoMUdpM5SEYRqP7UQgh 9nASG/fMJGKS3/VNXTnEGXx1fB/qrsHScF1hpphFcCmTWWAwLugx+QxV4i3YLsK75B7C 0u2Ejd0/tdqY1lmLOIgZ5P+VJc9AwCD5dNBVkgUobkVHcgZBYcFG/UT0MfV3rORtHMpM hpjuY4cYPiuMqDVLTgWiD5SoNERkAxeMJZgVZ6t+4ISqOy656FKgi7UmW9nv/kAwZ1uv FX0Q== X-Gm-Message-State: AOAM530qDIifu1f+S04OggGcw9BG/fQORLLUkV5uyOxPYyE4958SdQkV gh/q9zVxfEibCBufyKH5JGe0C/OqkbQ16w== X-Google-Smtp-Source: ABdhPJwqZx/glrGRlZ4FFqZDEdW3rnd8kteewGEVbFmXHEN43ZtjopbI1n4inIB5YpkFj6UroF5GSA== X-Received: by 2002:ac8:5a4a:: with SMTP id o10mr50430331qta.91.1641422739802; Wed, 05 Jan 2022 14:45:39 -0800 (PST) Received: from localhost (68-20-11-88.lightspeed.rlghnc.sbcglobal.net. [68.20.11.88]) by smtp.gmail.com with ESMTPSA id s126sm132403qkf.7.2022.01.05.14.45.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jan 2022 14:45:39 -0800 (PST) Date: Wed, 5 Jan 2022 17:45:38 -0500 From: Austin Ray To: notmuch@notmuchmail.org Subject: Memory leak in notmuch_database_destroy() Message-ID: <20220105224538.m36lnjn7rf3ieonc@athena> MIME-Version: 1.0 Message-ID-Hash: 2FNXTP6W5OOSOSEJYEQQQXQWEJ6UT5KI X-Message-ID-Hash: 2FNXTP6W5OOSOSEJYEQQQXQWEJ6UT5KI 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; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: multipart/mixed; boundary="===============2794995994500008113==" X-Migadu-Flow: FLOW_IN X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1641422748; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type:list-id: list-help:list-owner:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=3/yyYvWqw7VZI3zTJfmyR+L2DclA+zF3tIL+vlknUd8=; b=pLQzxJhsf98M7imQBs2na/3Adoa28U5CwSWVMYu2+o9rR+h0M9RXp+qEEcQKD8AvH6wS9N hL22vOtxPrwaLDg8JaURt9AkRR5OWMhskn8HBljvRmwbAT45Aq+/Sgpwviml0UFFrpFm15 1rmeEY2e7g493WrNUS3CGl79Nu6SZi9UI//bJi7dPErcuKTSKbSmKK8fn21v3yLyY2Xx1r AJHXWe+7tpHOkE0TM+oPh9DVsrVgW5D88bFReHtHjYaYpHeW47ZbXJIwO6R1GNtJ/kae4U y+Z2THUouGwZzDezgREKo+rj2GkqgJPTNkTUJRwnED5vWavGl326C8EuuvcBQQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1641422748; a=rsa-sha256; cv=none; b=I3lhSt0QAMpdWKh7fKWhlxSz53cpI0crTv3iwtYBlkKc+h5ClmrUK79rn3JPGokhXsoEUr Di4BmepzcQ7a0tsNl+GkiEA/s89FEqbdhssaHvNHWNOIcgpCrqlqYHI3iv55ImNqrPVqxl 8LUVEJQhNlP/U8qEOFpvr6tLsrrxaxwzuqxgw92mb10AZyEmhCzMgdtwu0cfF4NNMMeD8S pM0zuh8odUbavQhv0C27Ei/3tU3vHKvS17NVFSn2W+T77c09ECz5jU1IOw3xbbqGSpoXnw n5g6G9Fwt5vAZXljm+f2wSzqF/qLznWsTBXWFhCQ0cR0AW44JPFG+SG/wBRvvQ== 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=wdTnYjHs; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -2.91 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=austinray-io.20210112.gappssmtp.com header.s=20210112 header.b=wdTnYjHs; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 951262FF54 X-Spam-Score: -2.91 X-Migadu-Scanner: scn1.migadu.com X-TUID: 3J84eznbc4YP --===============2794995994500008113== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="jym4lbfrfz6yoobv" Content-Disposition: inline --jym4lbfrfz6yoobv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, libnotmuch 5.5.0 (notmuch 0.34.2) leaks memory when opening a database with 'notmuch_database_open_with_config()' and cleaning it up with 'notmuch_database_destroy()'. I've included a reproducer program (based on an existing notmuch test) and ASAN output below. Replacing 'notmuch_database_destroy()' with 'notmuch_database_close()' or omitting the database clean-up entirely resolves all but the first ASAN entry. There's no leak if 'notmuch_database_open_with_config()' returns an error. Thanks! Austin Reproducer program: #include #include int main(int argc, char **argv) { notmuch_database_t *db =3D NULL; notmuch_status_t st =3D notmuch_database_open_with_config( argv[1], NOTMUCH_DATABASE_MODE_READ_ONLY, argv[2], NULL, &db, NULL); if (db !=3D NULL) { notmuch_database_destroy(db); } printf("db !=3D NULL: %d\n", db !=3D NULL); } ASAN output: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D1059281=3D=3DERROR: LeakSanitizer: detected memory leaks Direct leak of 32 byte(s) in 1 object(s) allocated from: #0 0x7fb9d1230777 in __interceptor_malloc (/usr/lib/gcc/x86_64-pc-linux= -gnu/11.2.0/libasan.so.6+0xb6777) #1 0x7fb9d0a2b098 in g_malloc (/usr/lib64/libglib-2.0.so.0+0x5b098) Direct leak of 8 byte(s) in 1 object(s) allocated from: #0 0x7fb9d1232137 in operator new(unsigned long) (/usr/lib/gcc/x86_64-p= c-linux-gnu/11.2.0/libasan.so.6+0xb8137) #1 0x7fb9d1164ef4 (/usr/lib64/libnotmuch.so.5+0x2aef4) #2 0x7fb9d1165abc in notmuch_database_open_with_config (/usr/lib64/libn= otmuch.so.5+0x2babc) Indirect leak of 56 byte(s) in 1 object(s) allocated from: #0 0x7fb9d1232137 in operator new(unsigned long) (/usr/lib/gcc/x86_64-p= c-linux-gnu/11.2.0/libasan.so.6+0xb8137) #1 0x7fb9d08ef849 (/usr/lib64/libxapian.so.30+0x15d849) #2 0x7fb9d1165abc in notmuch_database_open_with_config (/usr/lib64/libn= otmuch.so.5+0x2babc) Indirect leak of 25 byte(s) in 1 object(s) allocated from: #0 0x7fb9d1230777 in __interceptor_malloc (/usr/lib/gcc/x86_64-pc-linux= -gnu/11.2.0/libasan.so.6+0xb6777) #1 0x7fb9d08efded (/usr/lib64/libxapian.so.30+0x15dded) SUMMARY: AddressSanitizer: 121 byte(s) leaked in 4 allocation(s). --=20 https://austinray.io Open Source Maintainer, Software Engineer, Keyboard Enthusiast GPG: 0127 ED83 B939 CCC9 8082 476E 1AA0 B115 C8AC 2C9E --jym4lbfrfz6yoobv Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQTaYk66K9eIYbyUx+6J1sK5lQPcSQUCYdYfjgAKCRCJ1sK5lQPc SYhgAP9dePBiaFdxh/ICjmKH4gC7O8uMINnM6O97qc+7Er3VJAD+Le9KxgNqTZL1 aZPjrKQRHCXMe/nctUdTQbn408GTtwE= =JgEH -----END PGP SIGNATURE----- --jym4lbfrfz6yoobv-- --===============2794995994500008113== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============2794995994500008113==--