notmuch breaks on \. in config file with upgrade from glib2 2.76.1 to 2.76.5

Subject: notmuch breaks on \. in config file with upgrade from glib2 2.76.1 to 2.76.5

Date: Wed, 6 Sep 2023 07:49:11 -0500

To: notmuch@notmuchmail.org

Cc:

From: Eric Blake


Summarizing a regression bug I first reported on IRC, which I hit on
Fedora 38.  These steps reproduce it without impacting anything else
you may have on your system:

$ rpm -q notmuch
notmuch-0.37-5.fc38.x86_64
$ sudo dnf downgrade -y glib2*.x86_64 glib2*.i686
<...>
$ rpm -q glib2
glib2-2.76.1-1.fc38.x86_64
glib2-2.76.1-1.fc38.i686
$ mkdir /tmp/foo
$ cd /tmp/foo
$ cat >.notmuch-config <<EOF
[database]
path=$PWD
EOF
$ yes $'\n' | NOTMUCH_notmuch --config=$PWD/.notmuch-config setup
<...>
$ notmuch --config=$PWD/.notmuch-config new
Found 1 total files (that's not much mail).
Note: Ignoring non-mail file: /tmp/foo/.notmuch-config
Processed 1 file in almost no time.
No new mail.
$ notmuch --config=$PWD/.notmuch-config config set query.q1 'from:/.*\.example\.org/'
$ printf 'q2=from:"/.*\\.example\\.org/"\n' >> .notmuch-config
$ tail -n3 .notmuch-config
[query]
q1=from:/.*\\.example\\.org/
q2=from:"/.*\.example\.org/"
$ notmuch --config=$PWD/.notmuch-config config get query.q1
from:/.*\.example\.org/
$ notmuch --config=$PWD/.notmuch-config config get query.q2
from:"/.*\.example\.org/"
$ notmuch --config=$PWD/.notmuch-config count
0
$ sudo dnf upgrade -y
$ rpm -q glib2
glib2-2.76.5-1.fc38.x86_64
glib2-2.76.5-1.fc38.i686
$ notmuch --config=$PWD/.notmuch-config config list
$ echo $?
0
$ notmuch --config=$PWD/.notmuch-config count
$ echo $?
1

Yikes - any configuration I wrote using 'notmuch config set' is stored
by older glib in a way that newer glib can still read.  But any
configuration that I manually added directly into the config file
might contain data that older glib can parse but newer glib rejects.
In this particular case, it looks like older glib happily treats "\."
as a string with two literal characters, while newer glib is trying to
treat it as an escape sequence and failing.  This failure is then
poorly handled by notmuch, which has knock-on odd effects ('config
list' producing no output but exiting successfully!, 'count' producing
no output but giving no error message why, etc.).

Last night, I filed
https://bugzilla.redhat.com/show_bug.cgi?id=2237562.  Later, I found
this about glib 2.77 introducing regressions:
https://bugzilla.redhat.com/show_bug.cgi?id=2225257; looks like Fedora
backported enough of that into 2.76.5 to cause similar issues in
relation to 2.76.1, even though a patchlevel release of glib shouldn't
be changing behaviors.

I presume that 'notmuch config set' should be the preferred way to
modify the config file - but since it IS a human-readable file,
notmuch should do a much better job of reporting errors whenever
glib's gkeyfile API cannot parse the file (even if that failure to
parse is caused by an unintended regression in glib behavior for
rejecting something it used to accept).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization:  qemu.org | libguestfs.org

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

Thread: