Re: [bug] possible condition depending on uninitialized value in _notmuch_message_sync

Subject: Re: [bug] possible condition depending on uninitialized value in _notmuch_message_sync

Date: Mon, 16 May 2022 04:33:36 -0700

To: David Bremner, notmuch@notmuchmail.org

Cc:

From: Eliza Velasquez


On Mon, May 16 2022 at 06:47 -03, David Bremner <david@tethera.net> wrote:

> Ideally of course I'd like a reproducer in C.  It would help to have
> line numbers in the valgrind output. It might be enough you install the
> notmuch debug symbols?

Took me a while to figure out the debugging workflow in NixOS, but I
managed to capture the line numbers. At messsage.cc:1333, at the second
condition below:

--8<---------------cut here---------------start------------->8---
/* Synchronize changes made to message->doc out into the database. */
void
_notmuch_message_sync (notmuch_message_t *message)
{
    if (_notmuch_database_mode (message->notmuch) == NOTMUCH_DATABASE_MODE_READ_ONLY)
	return;

    if (! message->modified)
	return;

    ...
}
--8<---------------cut here---------------end--------------->8---

It becomes very clear why this error only happens when removing a
non-existent tag if you look at at message.cc:1570...

--8<---------------cut here---------------start------------->8---
    try {
	message->doc.remove_term (term);
	message->modified = true;
    } catch (const Xapian::InvalidArgumentError) {
	/* We'll let the philosophers try to wrestle with the
	 * question of whether failing to remove that which was not
	 * there in the first place is failure. For us, we'll silently
	 * consider it all good. */
    }
--8<---------------cut here---------------end--------------->8---

So I guess `message->modified' isn't correctly initialized, at least
according to valgrind.

-- 
Eliza
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: