BUG: ruby segfault in notmuch_rb_tags_each

Subject: BUG: ruby segfault in notmuch_rb_tags_each

Date: Sat, 30 Apr 2022 13:47:26 -0700

To: notmuch@notmuchmail.org

Cc:

From: arcnmx


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).
I've attached my test case and parts of my logs showing the problem, but
you can also view the full logs online:
https://github.com/arcnmx/notmuch-vim/runs/6242139879
<https://github.com/arcnmx/notmuch-vim/runs/6242139879?check_suite_focus=true>
The most interesting part is the valgrind segment, while the ruby crash
logs pinpoint the issue to line 43 of test.rb:
https://github.com/arcnmx/notmuch-vim/blob/e981e3374250a8a04709b8a5143dee6f33ed04ce/test.rb#L43

To reproduce the issue, I created a github actions workflow that triggers
the issue: https://github.com/arcnmx/notmuch-vim/tree/notmuch-segfault-repro
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
<http://nixos.org>: 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!
test.rb (application/x-ruby)
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: