unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Memory leak in notmuch_database_destroy()
@ 2022-01-05 22:45 Austin Ray
  2022-01-08 18:28 ` [PATCH 1/2] lib/config: move g_key_File_get_string before continue David Bremner
  2022-01-24 14:58 ` Memory leak in notmuch_database_destroy() David Bremner
  0 siblings, 2 replies; 4+ messages in thread
From: Austin Ray @ 2022-01-05 22:45 UTC (permalink / raw)
  To: notmuch


[-- Attachment #1.1: Type: text/plain, Size: 2423 bytes --]

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 <notmuch.h>
#include <stdio.h>

int main(int argc, char **argv) {
  notmuch_database_t *db = NULL;

  notmuch_status_t st = notmuch_database_open_with_config(
      argv[1], NOTMUCH_DATABASE_MODE_READ_ONLY, argv[2], NULL, &db, NULL);

  if (db != NULL) {
    notmuch_database_destroy(db);
  }

  printf("db != NULL: %d\n", db != NULL);
}

ASAN output:

=================================================================
==1059281==ERROR: 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-pc-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/libnotmuch.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-pc-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/libnotmuch.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).

-- 
https://austinray.io
Open Source Maintainer, Software Engineer, Keyboard Enthusiast
GPG: 0127 ED83 B939 CCC9 8082 476E 1AA0 B115 C8AC 2C9E

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-24 14:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-05 22:45 Memory leak in notmuch_database_destroy() Austin Ray
2022-01-08 18:28 ` [PATCH 1/2] lib/config: move g_key_File_get_string before continue David Bremner
2022-01-08 18:28   ` [PATCH 2/2] lib/database: delete stemmer on destroy David Bremner
2022-01-24 14:58 ` Memory leak in notmuch_database_destroy() David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).