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
Add skip_quoted_offset variable #4
Conversation
Tunable for number of lines of quoted text that are displayed before the unquoted text after 'skip to quoted' command (S). Signed-off-by: David Sterba <dsterba@suse.cz>
@kdave However, I was put into a bit of a panic over your expression "Testing the neomutt workflow". Reading that, I realised that I didn't know how all the branches should fit together. Fortunately, I drew a new diagram and all's well. Rather than merge the change directly, I'll put it in its own feature branch. Some time soon, I want to be able to sell the Mutt-devs on each feature. https://github.com/neomutt/neomutt/tree/feature/skip-quoted Thanks. |
Neomutt would segfault if the mail that should be inserted into the header cache doesn't exist / failed to parse. I was previously observing the following crash: > $ bt > #0 memcpy (__len=0xa8, __src=0x0, __dest=0x7ffdcc8a8890) at /nix/store/hycbi8v31600cimx211ilj8p922nharl-glibc-2.30-dev/include/bits/string_fortified.h:34 > neomutt#1 dump (uidvalidity=0x0, off=0x7ffdcc8a8884, e=0x0, hc=0xc18330) at hcache/hcache.c:164 > neomutt#2 mutt_hcache_store (hc=hc@entry=0xc18330, key=0xc7d820 "/some/path/that/doesn't exist", > keylen=0x65, e=e@entry=0x0, uidvalidity=uidvalidity@entry=0x0) at hcache/hcache.c:592 > neomutt#3 0x000000000049d677 in append_message (h=h@entry=0xc18330, m=m@entry=0xc10580, q=q@entry=0xc3f460, msg=msg@entry=0xc0e4b0, dedup=dedup@entry=0x0) > at notmuch/mutt_notmuch.c:971 > neomutt#4 0x000000000049dd3c in read_mesgs_query (dedup=0x0, q=0xc3f460, m=0xc10580) at notmuch/mutt_notmuch.c:1125 > neomutt#5 nm_mbox_open (m=0xc10580) at notmuch/mutt_notmuch.c:2171 > neomutt#6 0x000000000044ee5e in mx_mbox_open (m=0xc10580, flags=<optimized out>) at mx.c:369 > neomutt#7 0x000000000043e574 in main (argc=0x1, argv=<optimized out>, envp=<optimized out>) at main.c:1152 > neomutt#8 0x00007f53c2303d8b in __libc_start_main () from /nix/store/9rabxvqbv0vgjmydiv59wkz768b5fmbc-glibc-2.30/lib/libc.so.6 > neomutt#9 0x000000000040bf6a in _start () at ../sysdeps/x86_64/start.S:120
Check if the mail was parsed before storing it in hcache. Neomutt would segfault if the mail that should be inserted into the header cache doesn't exist / failed to parse. I was previously observing the following crash: > $ bt > #0 memcpy (__len=0xa8, __src=0x0, __dest=0x7ffdcc8a8890) at /nix/store/hycbi8v31600cimx211ilj8p922nharl-glibc-2.30-dev/include/bits/string_fortified.h:34 > neomutt#1 dump (uidvalidity=0x0, off=0x7ffdcc8a8884, e=0x0, hc=0xc18330) at hcache/hcache.c:164 > neomutt#2 mutt_hcache_store (hc=hc@entry=0xc18330, key=0xc7d820 "/some/path/that/doesn't exist", > keylen=0x65, e=e@entry=0x0, uidvalidity=uidvalidity@entry=0x0) at hcache/hcache.c:592 > neomutt#3 0x000000000049d677 in append_message (h=h@entry=0xc18330, m=m@entry=0xc10580, q=q@entry=0xc3f460, msg=msg@entry=0xc0e4b0, dedup=dedup@entry=0x0) > at notmuch/mutt_notmuch.c:971 > neomutt#4 0x000000000049dd3c in read_mesgs_query (dedup=0x0, q=0xc3f460, m=0xc10580) at notmuch/mutt_notmuch.c:1125 > neomutt#5 nm_mbox_open (m=0xc10580) at notmuch/mutt_notmuch.c:2171 > neomutt#6 0x000000000044ee5e in mx_mbox_open (m=0xc10580, flags=<optimized out>) at mx.c:369 > neomutt#7 0x000000000043e574 in main (argc=0x1, argv=<optimized out>, envp=<optimized out>) at main.c:1152 > neomutt#8 0x00007f53c2303d8b in __libc_start_main () from /nix/store/9rabxvqbv0vgjmydiv59wkz768b5fmbc-glibc-2.30/lib/libc.so.6 > neomutt#9 0x000000000040bf6a in _start () at ../sysdeps/x86_64/start.S:120
Check if the mail was parsed before storing it in hcache. Neomutt would segfault if the mail that should be inserted into the header cache doesn't exist / failed to parse. I was previously observing the following crash: > $ bt > #0 memcpy (__len=0xa8, __src=0x0, __dest=0x7ffdcc8a8890) at /nix/store/hycbi8v31600cimx211ilj8p922nharl-glibc-2.30-dev/include/bits/string_fortified.h:34 > #1 dump (uidvalidity=0x0, off=0x7ffdcc8a8884, e=0x0, hc=0xc18330) at hcache/hcache.c:164 > #2 mutt_hcache_store (hc=hc@entry=0xc18330, key=0xc7d820 "/some/path/that/doesn't exist", > keylen=0x65, e=e@entry=0x0, uidvalidity=uidvalidity@entry=0x0) at hcache/hcache.c:592 > #3 0x000000000049d677 in append_message (h=h@entry=0xc18330, m=m@entry=0xc10580, q=q@entry=0xc3f460, msg=msg@entry=0xc0e4b0, dedup=dedup@entry=0x0) > at notmuch/mutt_notmuch.c:971 > #4 0x000000000049dd3c in read_mesgs_query (dedup=0x0, q=0xc3f460, m=0xc10580) at notmuch/mutt_notmuch.c:1125 > #5 nm_mbox_open (m=0xc10580) at notmuch/mutt_notmuch.c:2171 > #6 0x000000000044ee5e in mx_mbox_open (m=0xc10580, flags=<optimized out>) at mx.c:369 > #7 0x000000000043e574 in main (argc=0x1, argv=<optimized out>, envp=<optimized out>) at main.c:1152 > #8 0x00007f53c2303d8b in __libc_start_main () from /nix/store/9rabxvqbv0vgjmydiv59wkz768b5fmbc-glibc-2.30/lib/libc.so.6 > #9 0x000000000040bf6a in _start () at ../sysdeps/x86_64/start.S:120
NeoMutt segfaults on OpenBSD current. ``` (gdb) bt #0 _libc_freeaddrinfo (ai=0x0) at /usr/src/lib/libc/net/freeaddrinfo.c:46 #1 0x0000075218dbab26 in getdnsdomainname (result=0x754f5ca5a80) at ../neomutt-20211015/conn/getdomain.c:152 #2 0x0000075218d13f6f in get_hostname (cs=0x754f5cac000) at ../neomutt-20211015/init.c:357 #3 mutt_init (cs=<optimized out>, skip_sys_rc=<optimized out>, commands=0x7f7ffffed558) at ../neomutt-20211015/init.c:919 #4 0x0000075218d1cc64 in main (argc=1, argv=0x7f7ffffed748, envp=<optimized out>) at ../neomutt-20211015/main.c:786 ``` It seems that `freeaddrinfo()` tries to release a structure, which has not been allocated. Proposed fix is to check before releasing.
I just got a crash after hotmail closed the IMAP connection and I was left with an empty mailbox: ``` (gdb) bt #0 0x00000000003b4d9b in mutt_hash_free (ptr=0x10) at mutt/hash.c:459 #1 0x000000000028dd34 in mutt_thread_ctx_free (ptr=0x801461b08) at mutt_thread.c:369 #2 0x00000000002922f8 in mview_free (ptr=0x801a00950) at mview.c:63 #3 0x00000000002a2edc in mutt_index_menu (dlg=0x80145d9a0, m_init=0x801483100) at index/dlg_index.c:1154 #4 0x00000000002847ae in main (argc=1, argv=0x7fffffffe848, envp=0x7fffffffe858) at main.c:1361 ``` This PR mitigates it by checking a pointer before free'ing it.
I just got a crash after hotmail closed the IMAP connection and I was left with an empty mailbox: ``` (gdb) bt #0 0x00000000003b4d9b in mutt_hash_free (ptr=0x10) at mutt/hash.c:459 #1 0x000000000028dd34 in mutt_thread_ctx_free (ptr=0x801461b08) at mutt_thread.c:369 #2 0x00000000002922f8 in mview_free (ptr=0x801a00950) at mview.c:63 #3 0x00000000002a2edc in mutt_index_menu (dlg=0x80145d9a0, m_init=0x801483100) at index/dlg_index.c:1154 #4 0x00000000002847ae in main (argc=1, argv=0x7fffffffe848, envp=0x7fffffffe858) at main.c:1361 ``` This PR mitigates it by checking a pointer before free'ing it.
I've just been hit by a crash when triggering the machinery (sourcing config files) to connect to an IMAP account after the connection dropped. As part of the machinery, there's an `alternates` command being triggered. This ends up with the following stack trace: ``` (gdb) bt #0 0x00000000002602b6 in mutt_alternates_reset (mv=0x6e1ca84c7d0) at alternates.c:80 #1 0x00000000002a8f13 in index_altern_observer (nc=0x8209c3238) at index/index.c:231 #2 0x00000000003c7883 in send (source=0x6e1ca8c69e0, current=0x6e1ca83b180, event_type=NT_ALTERN, event_subtype=1, event_data=0x0) at mutt/notify.c:132 #3 0x00000000003c7935 in send (source=0x6e1ca8c69e0, current=0x6e1ca8c69e0, event_type=NT_ALTERN, event_subtype=1, event_data=0x0) at mutt/notify.c:140 #4 0x00000000003c775d in notify_send (notify=0x6e1ca8c69e0, event_type=NT_ALTERN, event_subtype=1, event_data=0x0) at mutt/notify.c:176 #5 0x0000000000260483 in parse_alternates (buf=0x6e1ca83b480, s=0x6e1ca83b380, data=0, err=0x6e1ca83b300) at alternates.c:116 ``` In `mutt_alternates_reset`, we go over `m->msg_count`, but the current mailbox is blank, except for some counters. In particular, `msg_count` and the `emails` array clearly disagree: ``` (gdb) p *m $3 = {pathbuf = {data = 0x0, dptr = 0x0, dsize = 0}, realpath = 0x0, name = 0x0, sub = 0x0, size = 12847, has_new = false, msg_count = 3, msg_unread = 2, msg_flagged = 0, msg_new = 2, msg_deleted = 0, msg_tagged = 0, emails = 0x0, email_max = 25, v2r = 0x0, vcount = 0, notified = false, type = MUTT_IMAP, newly_created = false, last_visited = {tv_sec = 1709195964, tv_nsec = 942447048}, last_checked = 1709196039, mx_ops = 0x237a00 <ImapCommands+32>, append = false, changed = true, dontwrite = false, first_check_stats_done = true, notify_user = true, peekonly = false, poll_new_mail = true, readonly = false, verbose = true, rights = 2022, compress_info = 0x0, id_hash = 0x0, subj_hash = 0x0, label_hash = 0x0, account = 0x0, opened = 0, visible = false, mdata = 0x0, mdata_free = 0x376b30 <__getCurrentRuneLocale+80>, notify = 0x0, gen = -1} ```
I've just been hit by a crash when triggering the machinery (sourcing config files) to connect to an IMAP account after the connection dropped. As part of the machinery, there's an `alternates` command being triggered. This ends up with the following stack trace: ``` (gdb) bt #0 0x00000000002602b6 in mutt_alternates_reset (mv=0x6e1ca84c7d0) at alternates.c:80 #1 0x00000000002a8f13 in index_altern_observer (nc=0x8209c3238) at index/index.c:231 #2 0x00000000003c7883 in send (source=0x6e1ca8c69e0, current=0x6e1ca83b180, event_type=NT_ALTERN, event_subtype=1, event_data=0x0) at mutt/notify.c:132 #3 0x00000000003c7935 in send (source=0x6e1ca8c69e0, current=0x6e1ca8c69e0, event_type=NT_ALTERN, event_subtype=1, event_data=0x0) at mutt/notify.c:140 #4 0x00000000003c775d in notify_send (notify=0x6e1ca8c69e0, event_type=NT_ALTERN, event_subtype=1, event_data=0x0) at mutt/notify.c:176 #5 0x0000000000260483 in parse_alternates (buf=0x6e1ca83b480, s=0x6e1ca83b380, data=0, err=0x6e1ca83b300) at alternates.c:116 ``` In `mutt_alternates_reset`, we go over `m->msg_count`, but the current mailbox is blank, except for some counters. In particular, `msg_count` and the `emails` array clearly disagree: ``` (gdb) p *m $3 = {pathbuf = {data = 0x0, dptr = 0x0, dsize = 0}, realpath = 0x0, name = 0x0, sub = 0x0, size = 12847, has_new = false, msg_count = 3, msg_unread = 2, msg_flagged = 0, msg_new = 2, msg_deleted = 0, msg_tagged = 0, emails = 0x0, email_max = 25, v2r = 0x0, vcount = 0, notified = false, type = MUTT_IMAP, newly_created = false, last_visited = {tv_sec = 1709195964, tv_nsec = 942447048}, last_checked = 1709196039, mx_ops = 0x237a00 <ImapCommands+32>, append = false, changed = true, dontwrite = false, first_check_stats_done = true, notify_user = true, peekonly = false, poll_new_mail = true, readonly = false, verbose = true, rights = 2022, compress_info = 0x0, id_hash = 0x0, subj_hash = 0x0, label_hash = 0x0, account = 0x0, opened = 0, visible = false, mdata = 0x0, mdata_free = 0x376b30 <__getCurrentRuneLocale+80>, notify = 0x0, gen = -1} ```
I've just been hit by a crash when triggering the machinery (sourcing config files) to connect to an IMAP account after the connection dropped. As part of the machinery, there's an `alternates` command being triggered. This ends up with the following stack trace: ``` (gdb) bt #0 0x00000000002602b6 in mutt_alternates_reset (mv=0x6e1ca84c7d0) at alternates.c:80 #1 0x00000000002a8f13 in index_altern_observer (nc=0x8209c3238) at index/index.c:231 #2 0x00000000003c7883 in send (source=0x6e1ca8c69e0, current=0x6e1ca83b180, event_type=NT_ALTERN, event_subtype=1, event_data=0x0) at mutt/notify.c:132 #3 0x00000000003c7935 in send (source=0x6e1ca8c69e0, current=0x6e1ca8c69e0, event_type=NT_ALTERN, event_subtype=1, event_data=0x0) at mutt/notify.c:140 #4 0x00000000003c775d in notify_send (notify=0x6e1ca8c69e0, event_type=NT_ALTERN, event_subtype=1, event_data=0x0) at mutt/notify.c:176 #5 0x0000000000260483 in parse_alternates (buf=0x6e1ca83b480, s=0x6e1ca83b380, data=0, err=0x6e1ca83b300) at alternates.c:116 ``` In `mutt_alternates_reset`, we go over `m->msg_count`, but the current mailbox is blank, except for some counters. In particular, `msg_count` and the `emails` array clearly disagree: ``` (gdb) p *m $3 = {pathbuf = {data = 0x0, dptr = 0x0, dsize = 0}, realpath = 0x0, name = 0x0, sub = 0x0, size = 12847, has_new = false, msg_count = 3, msg_unread = 2, msg_flagged = 0, msg_new = 2, msg_deleted = 0, msg_tagged = 0, emails = 0x0, email_max = 25, v2r = 0x0, vcount = 0, notified = false, type = MUTT_IMAP, newly_created = false, last_visited = {tv_sec = 1709195964, tv_nsec = 942447048}, last_checked = 1709196039, mx_ops = 0x237a00 <ImapCommands+32>, append = false, changed = true, dontwrite = false, first_check_stats_done = true, notify_user = true, peekonly = false, poll_new_mail = true, readonly = false, verbose = true, rights = 2022, compress_info = 0x0, id_hash = 0x0, subj_hash = 0x0, label_hash = 0x0, account = 0x0, opened = 0, visible = false, mdata = 0x0, mdata_free = 0x376b30 <__getCurrentRuneLocale+80>, notify = 0x0, gen = -1} ```
I've just been hit by a crash when triggering the machinery (sourcing config files) to connect to an IMAP account after the connection dropped. As part of the machinery, there's an `alternates` command being triggered. This ends up with the following stack trace: ``` (gdb) bt #0 0x00000000002602b6 in mutt_alternates_reset (mv=0x6e1ca84c7d0) at alternates.c:80 #1 0x00000000002a8f13 in index_altern_observer (nc=0x8209c3238) at index/index.c:231 #2 0x00000000003c7883 in send (source=0x6e1ca8c69e0, current=0x6e1ca83b180, event_type=NT_ALTERN, event_subtype=1, event_data=0x0) at mutt/notify.c:132 #3 0x00000000003c7935 in send (source=0x6e1ca8c69e0, current=0x6e1ca8c69e0, event_type=NT_ALTERN, event_subtype=1, event_data=0x0) at mutt/notify.c:140 #4 0x00000000003c775d in notify_send (notify=0x6e1ca8c69e0, event_type=NT_ALTERN, event_subtype=1, event_data=0x0) at mutt/notify.c:176 #5 0x0000000000260483 in parse_alternates (buf=0x6e1ca83b480, s=0x6e1ca83b380, data=0, err=0x6e1ca83b300) at alternates.c:116 ``` In `mutt_alternates_reset`, we go over `m->msg_count`, but the current mailbox is blank, except for some counters. In particular, `msg_count` and the `emails` array clearly disagree: ``` (gdb) p *m $3 = {pathbuf = {data = 0x0, dptr = 0x0, dsize = 0}, realpath = 0x0, name = 0x0, sub = 0x0, size = 12847, has_new = false, msg_count = 3, msg_unread = 2, msg_flagged = 0, msg_new = 2, msg_deleted = 0, msg_tagged = 0, emails = 0x0, email_max = 25, v2r = 0x0, vcount = 0, notified = false, type = MUTT_IMAP, newly_created = false, last_visited = {tv_sec = 1709195964, tv_nsec = 942447048}, last_checked = 1709196039, mx_ops = 0x237a00 <ImapCommands+32>, append = false, changed = true, dontwrite = false, first_check_stats_done = true, notify_user = true, peekonly = false, poll_new_mail = true, readonly = false, verbose = true, rights = 2022, compress_info = 0x0, id_hash = 0x0, subj_hash = 0x0, label_hash = 0x0, account = 0x0, opened = 0, visible = false, mdata = 0x0, mdata_free = 0x376b30 <__getCurrentRuneLocale+80>, notify = 0x0, gen = -1} ```
I've just been hit by a crash when triggering the machinery (sourcing config files) to connect to an IMAP account after the connection dropped. As part of the machinery, there's an `alternates` command being triggered. This ends up with the following stack trace: ``` (gdb) bt #0 0x00000000002602b6 in mutt_alternates_reset (mv=0x6e1ca84c7d0) at alternates.c:80 #1 0x00000000002a8f13 in index_altern_observer (nc=0x8209c3238) at index/index.c:231 #2 0x00000000003c7883 in send (source=0x6e1ca8c69e0, current=0x6e1ca83b180, event_type=NT_ALTERN, event_subtype=1, event_data=0x0) at mutt/notify.c:132 #3 0x00000000003c7935 in send (source=0x6e1ca8c69e0, current=0x6e1ca8c69e0, event_type=NT_ALTERN, event_subtype=1, event_data=0x0) at mutt/notify.c:140 #4 0x00000000003c775d in notify_send (notify=0x6e1ca8c69e0, event_type=NT_ALTERN, event_subtype=1, event_data=0x0) at mutt/notify.c:176 #5 0x0000000000260483 in parse_alternates (buf=0x6e1ca83b480, s=0x6e1ca83b380, data=0, err=0x6e1ca83b300) at alternates.c:116 ``` In `mutt_alternates_reset`, we go over `m->msg_count`, but the current mailbox is blank, except for some counters. In particular, `msg_count` and the `emails` array clearly disagree: ``` (gdb) p *m $3 = {pathbuf = {data = 0x0, dptr = 0x0, dsize = 0}, realpath = 0x0, name = 0x0, sub = 0x0, size = 12847, has_new = false, msg_count = 3, msg_unread = 2, msg_flagged = 0, msg_new = 2, msg_deleted = 0, msg_tagged = 0, emails = 0x0, email_max = 25, v2r = 0x0, vcount = 0, notified = false, type = MUTT_IMAP, newly_created = false, last_visited = {tv_sec = 1709195964, tv_nsec = 942447048}, last_checked = 1709196039, mx_ops = 0x237a00 <ImapCommands+32>, append = false, changed = true, dontwrite = false, first_check_stats_done = true, notify_user = true, peekonly = false, poll_new_mail = true, readonly = false, verbose = true, rights = 2022, compress_info = 0x0, id_hash = 0x0, subj_hash = 0x0, label_hash = 0x0, account = 0x0, opened = 0, visible = false, mdata = 0x0, mdata_free = 0x376b30 <__getCurrentRuneLocale+80>, notify = 0x0, gen = -1} ```
Testing the neomutt workflow with a simple feature patch from my local stash.
Tunable for number of lines of quoted text that are displayed before the
unquoted text after 'skip to quoted' command (S).
Signed-off-by: David Sterba dsterba@suse.cz