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



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
$ sudo dnf downgrade -y glib2*.x86_64 glib2*.i686
$ rpm -q glib2
$ mkdir /tmp/foo
$ cd /tmp/foo
$ cat >.notmuch-config <<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
$ notmuch --config=$PWD/.notmuch-config config get query.q1
$ notmuch --config=$PWD/.notmuch-config config get query.q2
$ notmuch --config=$PWD/.notmuch-config count
$ sudo dnf upgrade -y
$ rpm -q glib2
$ notmuch --config=$PWD/.notmuch-config config list
$ echo $?
$ notmuch --config=$PWD/.notmuch-config count
$ echo $?

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  Later, I found
this about glib 2.77 introducing regressions:; 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: |

notmuch mailing list --
To unsubscribe send an email to