notmuch: ignore blank lines in the query-map file v1 PROPOSED

Matt Snider: 1
 notmuch: ignore blank lines in the query-map file

 1 files changed, 5 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/aerc/patches/8850/mbox | git am -3
Learn more about email & git

[PATCH] notmuch: ignore blank lines in the query-map file Export this patch


This is a very small change, but as it is my first patch for aerc and first
time using `git send-email`, there may be some issues with formatting, etc. Let
me know if this is the case. Also, it's probably way too detailed for such
a minor change...

A segmentation fault occurs when using the notmuch backend and a `query-map`
file that contains blank lines. It seems that although
`worker/notmuch/worker.go:397` fails with an appropriate error,
`handleConnect()` is run anyways, and `w.db` is `nil` which causes the

It might make sense to have an additional check here and return another err
(e.g. "notmuch database is not initialized") from `handleConnect()`. I'm not
sure if this is right, because doing that, while preventing the segfault, just
causes the interface to load (spin, spin, ...). 

Here is the console output from the segfault:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x78c0a6]

goroutine 24 [running]:
git.sr.ht/~sircmpwn/aerc/worker/notmuch/lib.(*DB).connectRO(0x0, 0xc000024238, 0x98d200)
	/home/matt/opt/aerc/worker/notmuch/lib/database.go:45 +0x26
git.sr.ht/~sircmpwn/aerc/worker/notmuch.(*worker).handleConnect(0xc0000b24b0, 0xc0000a3420, 0x874001, 0xc0000a0101)
	/home/matt/opt/aerc/worker/notmuch/worker.go:132 +0x33
git.sr.ht/~sircmpwn/aerc/worker/notmuch.(*worker).handleMessage(0xc0000b24b0, 0x98d000, 0xc0000a3420, 0x98d000, 0xc0000a3420)
	/home/matt/opt/aerc/worker/notmuch/worker.go:78 +0x364
	/home/matt/opt/aerc/worker/notmuch/worker.go:48 +0x99
created by git.sr.ht/~sircmpwn/aerc/widgets.NewAccountView
	/home/matt/opt/aerc/widgets/account.go:74 +0x49b

 worker/notmuch/worker.go | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/worker/notmuch/worker.go b/worker/notmuch/worker.go
index 96adc29..685d24b 100644
--- a/worker/notmuch/worker.go
+++ b/worker/notmuch/worker.go
@@ -387,6 +387,11 @@ func (w *worker) loadQueryMap(acctConfig *config.AccountConfig) error {
	scanner := bufio.NewScanner(f)
	for scanner.Scan() {
		line := scanner.Text()
		// ignore blank lines
		if line == "" {

		split := strings.SplitN(line, "=", 2)
		if len(split) != 2 {
			return fmt.Errorf("invalid line %q, want name=query", line)
Hi Matt,
Thanks for sending in the patch, much appreciated.

Some comments below:

If you send a patch, everything you put into the mail prior to the 3 dashes
are taken as a commit message.
Now, generally you don't want discussions in there, but a concise summary of
what the patch does.
View this thread in the archives