Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault if nm_default_url not set #3036

Closed
p00f opened this issue Sep 14, 2021 · 10 comments
Closed

Segfault if nm_default_url not set #3036

p00f opened this issue Sep 14, 2021 · 10 comments
Labels

Comments

@p00f
Copy link

p00f commented Sep 14, 2021

Expected Behaviour

Set a notmuch virtual-mailboxes, forget to set nm_default_url and not have neomutt crash

Actual Behaviour

Neomutt crashes if there is a virtual notmuch mailbox and nm_default_url is not set

If NeoMutt crashed, did your OS create a 'coredump' file?
Yes,
coredump.zip

Sorry for the tarball inside zip, github won't let me upload zst

Steps to Reproduce

Described above

How often does this happen?

  • Always

When did it start to happen?

  • When I upgraded
    Which version did you use to use?

  • When I changed my config
    Can you narrow down what you changed?

NeoMutt Version

NeoMutt 20210205
Copyright (C) 1996-2020 Michael R. Elkins and others.
NeoMutt comes with ABSOLUTELY NO WARRANTY; for details type 'neomutt -vv'.
NeoMutt is free software, and you are welcome to redistribute it
under certain conditions; type 'neomutt -vv' for details.

System: Linux 5.14.2-arch1-2 (x86_64)
ncurses: ncurses 6.2.20200212 (compiled with 6.2.20200212)
libidn2: 2.3.2 (compiled with 2.3.0)
GPGME: 1.15.1
GnuTLS: 3.7.0
libnotmuch: 5.3.0
storage: kyotocabinet, gdbm, bdb, lmdb
compression: lz4, zlib, zstd

Configure options: --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib --gpgme --sqlite --autocrypt --lua --notmuch --gss --gnutls --sasl --with-ui=ncurses --with-idn2=/usr --disable-idn --idn2 --bdb --lmdb --kyotocabinet --gdbm --lz4 --zlib --zstd

Compilation CFLAGS: -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -std=c99 -fno-delete-null-pointer-checks -D_ALL_SOURCE=1 -D_GNU_SOURCE=1 -D__EXTENSIONS__ -I/usr/include -I/usr/include/lua5.3 -DNCURSES_WIDECHAR -I/include -I/usr/include/

Default options:
  +attach_headers_color +compose_to_sender +compress +cond_date +debug 
  +encrypt_to_self +forgotten_attachments +forwref +ifdef +imap +index_color 
  +initials +limit_current_thread +multiple_fcc +nested_if +new_mail +nntp +pop 
  +progress +quasi_delete +regcomp +reply_with_xorig +sensible_browser +sidebar 
  +skip_quoted +smtp +status_color +timeout +tls_sni +trash 

Compile options:
  +autocrypt +bkgdset +color +curs_set +fcntl -flock -fmemopen +futimens 
  +getaddrinfo +gnutls +gpgme +gss +hcache -homespool +idn +inotify 
  -locales_hack +lua +meta -mixmaster +nls +notmuch -openssl +pgp +regex +sasl 
  +smime +sqlite +start_color +sun_attachment +typeahead 
MAILPATH="/var/mail"
PKGDATADIR="/usr/share/neomutt"
SENDMAIL="/usr/sbin/sendmail"
SYSCONFDIR="/etc"

To learn more about NeoMutt, visit: https://neomutt.org
If you find a bug in NeoMutt, please raise an issue at:
    https://github.com/neomutt/neomutt/issues
or send an email to: <neomutt-devel@neomutt.org>

Extra Info

  • Operating System and its version - archlinux
  • Were you using multiple copies of NeoMutt at once? - no
  • Were you using 'screen' or 'tmux'? - no
  • Is your email local (maildir) or remote (IMAP)? - local

Config permalink - https://git.sr.ht/~p00f/dotfiles/tree/09fecccd652cc2dbd0186902969507af89fa60b9/item/neomutt/.config/neomutt/ I'll try to remember not to force push over this 😅

@p00f p00f added the type:bug Bug label Sep 14, 2021
@p00f
Copy link
Author

p00f commented Sep 14, 2021

Backtrace:

Reading symbols from /usr/bin/neomutt...
(No debugging symbols found in /usr/bin/neomutt)
[New LWP 21744]
[New LWP 21745]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Core was generated by `neomutt'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007fdf6bb508e7 in Xapian::QueryParser::parse_query(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsignedint, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from /usr/lib/libxapian.so.30
[Current thread is 1 (Thread 0x7fdf6b69d600 (LWP 21744))]
(gdb) backtrace
#0  0x00007fdf6bb508e7 in Xapian::QueryParser::parse_query(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsignedint, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () at /usr/lib/libxapian.so.30
#1  0x00007fdf6c9c7a0e in _notmuch_query_ensure_parsed(notmuch_query_t*) (query=0x55c42871ed10) at lib/query.cc:128
#2  0x00007fdf6c9c8337 in _notmuch_query_count_documents(notmuch_query_t*, char const*, unsigned int*)
    (query=0x55c42871ed10, type=0x7fdf6c9d87db "mail", count_out=0x7fffa77eb7b4) at lib/query.cc:613
#3  0x000055c4282b5e6c in  ()
#4  0x000055c4282b6090 in  ()
#5  0x000055c428271348 in  ()
#6  0x000055c4282570d3 in  ()
#7  0x000055c4282363fd in  ()
#8  0x00007fdf6c725b25 in __libc_start_main () at /usr/lib/libc.so.6
#9  0x000055c428236d8e in  ()

@bremner
Copy link

bremner commented Sep 14, 2021

Can you try this patch to notmuch? It might (or might not) get a more graceful error response.

From 4f2d2220228f4af2d1cdc7b188b44fbbbbdcae90 Mon Sep 17 00:00:00 2001
From: David Bremner <david@tethera.net>
Date: Tue, 14 Sep 2021 13:44:41 -0300
Subject: [PATCH] lib: add additional checks for null pointer in
 _n_q_ensure_parsed

---
 lib/query.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/query.cc b/lib/query.cc
index 792aba21..e7a197bc 100644
--- a/lib/query.cc
+++ b/lib/query.cc
@@ -119,6 +119,9 @@ notmuch_query_create (notmuch_database_t *notmuch,
 static notmuch_status_t
 _notmuch_query_ensure_parsed (notmuch_query_t *query)
 {
+    if (! query || ! query->query_string)
+	return NOTMUCH_STATUS_NULL_POINTER;
+
     if (query->parsed)
 	return NOTMUCH_STATUS_SUCCESS;
 
-- 
2.33.0

@p00f
Copy link
Author

p00f commented Sep 14, 2021

Just a minute

@p00f
Copy link
Author

p00f commented Sep 14, 2021

No difference

@austin-ray
Copy link
Contributor

austin-ray commented Sep 14, 2021 via email

@p00f
Copy link
Author

p00f commented Sep 14, 2021

No

@p00f
Copy link
Author

p00f commented Sep 14, 2021

I mean my notmuch database is in ~/Mail and my emails are in ~/Mail/account1/ and ~/Mail/account2/

@bremner
Copy link

bremner commented Sep 14, 2021

I can duplicate this with a trivial neomuttrc that looks like

virtual-mailboxes "My INBOX" "notmuch://?query=tag:inbox"

Poking about briefly in gdb, it looks like the notmuch_database_open* call failed and either did not report an error code, or the error code was ignored. I did not look (yet) at the neomutt code calling libnotmuch.

@austin-ray
Copy link
Contributor

austin-ray commented Sep 14, 2021 via email

@p00f
Copy link
Author

p00f commented Sep 14, 2021

Yes this is fixed in master. Sorry for the noise, I should've atleast checked master given that the version in the arch repos is not even the latest release

@p00f p00f closed this as completed Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants