Hi, I've been running into rare crashes via notmuch-vim for a while now and finally got around to tracking down the problem. I apologize for the size of the reproduction case, but at least it can be reproduced!
To summarize the problem, notmuch_tags_get appears to occasionally cause crashes when called from Ruby (I'm not sure if that method or the bindings are actually at fault or simply exposing some other memory corruption in the program, but it does appear to consistently trigger the crash).
The ruby script is pared-down from the vim plugin that's been triggering it, so is still a little large. The repo also includes mbox test data that triggers the issue, and can be run locally using
nix:
nix-shell --run "initmail; debugtest; runtest"(initmail sets up a temporary maildir/xapiandb, debugtest runs valgrind, runtest runs the script normally until it crashes)
I hope I've made it clear enough that someone could help figure out what's going on here, also let me know if I missed anything in this report, thanks!