Bug 2302132 - mbsync -a causes SIGSEGV
Summary: mbsync -a causes SIGSEGV
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: isync
Version: 40
Hardware: x86_64
OS: Linux
unspecified
urgent
Target Milestone: ---
Assignee: Fabian Affolter
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 2304747 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-07-31 19:15 UTC by Jarkko Sakkinen
Modified: 2024-10-05 22:35 UTC (History)
6 users (show)

Fixed In Version: isync-1.5.0-1.fc42 isync-1.5.0-2.fc41
Clone Of:
Environment:
Last Closed: 2024-10-05 22:35:57 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
isync-1.4.4-8.fc40.x86_64 (2.97 KB, text/plain)
2024-08-01 12:02 UTC, Jarkko Sakkinen
no flags Details
e70c300f7446 ("permit leading whitespace in INTERNALDATE strings") (2.58 KB, text/plain)
2024-08-01 12:04 UTC, Jarkko Sakkinen
no flags Details
Workaround for the GCC-14 issue (1.46 KB, application/mbox)
2024-08-01 18:43 UTC, Jarkko Sakkinen
no flags Details

Description Jarkko Sakkinen 2024-07-31 19:15:07 UTC
$ coredumpctl gdb /usr/bin/mbsync
           PID: 12415 (mbsync)
           UID: 1000 (jarkko)
           GID: 1000 (jarkko)
        Signal: 11 (SEGV)
     Timestamp: Wed 2024-07-31 21:11:06 EEST (58min ago)
  Command Line: mbsync -V kapsi
    Executable: /usr/bin/mbsync
 Control Group: /user.slice/user-1000.slice/user/session.slice/org.gnome.Shell
          Unit: user
     User Unit: org.gnome.Shell
         Slice: user-1000.slice
     Owner UID: 1000 (jarkko)
       Boot ID: a3338b4485bd4e139823e7800bb0864d
    Machine ID: bf49fbc0a2a1401ca2ee487d88d3e557
      Hostname: suppilovahvero
       Storage: /var/lib/systemd/coredump/core.mbsync.1000.a3338b4485bd4e139823e7800bb0864d.12415.1722449466000000.zst (present)
  Size on Disk: 522.5K
       Package: isync/1.4.4-8.fc40
      build-id: 3fb7ee1e76d56b433d695891b1affa4e116328b9
       Message: Process 12415 (mbsync) of user 1000 dumped core.

                Module libsasldb.so from rpm cyrus-sasl-2.1.28-19.fc40.x86_64
                Module libplain.so from rpm cyrus-sasl-2.1.28-19.fc40.x86_64
                Module liblogin.so from rpm cyrus-sasl-2.1.28-19.fc40.x86_64
                Module libpcre2-8.so.0 from rpm pcre2-10.44-1.fc40.x86_64
                Module libselinux.so.1 from rpm libselinux-3.6-4.fc40.x86_64
                Module libkeyutils.so.1 from rpm keyutils-1.6.3-3.fc40.x86_64
                Module libkrb5support.so.0 from rpm krb5-1.21.3-1.fc40.x86_64
                Module libcom_err.so.2 from rpm e2fsprogs-1.47.0-5.fc40.x86_64
                Module libk5crypto.so.3 from rpm krb5-1.21.3-1.fc40.x86_64
                Module libkrb5.so.3 from rpm krb5-1.21.3-1.fc40.x86_64
                Module libgssapi_krb5.so.2 from rpm krb5-1.21.3-1.fc40.x86_64
                Module libgssapiv2.so from rpm cyrus-sasl-2.1.28-19.fc40.x86_64
                Module libanonymous.so from rpm cyrus-sasl-2.1.28-19.fc40.x86_64
                Module libcap.so.2 from rpm libcap-2.69-8.fc40.x86_64
                Module libnss_resolve.so.2 from rpm systemd-255.10-1.fc40.x86_64
                Module libnss_mdns4_minimal.so.2 from rpm nss-mdns-0.15.1-11.fc40.x86_64
                Module libcrypt.so.2 from rpm libxcrypt-4.4.36-5.fc40.x86_64
                Module libz.so.1 from rpm zlib-ng-2.1.7-1.fc40.x86_64
                Module libsasl2.so.3 from rpm cyrus-sasl-2.1.28-19.fc40.x86_64
                Module libcrypto.so.3 from rpm openssl-3.2.1-2.fc40.x86_64
                Module libssl.so.3 from rpm openssl-3.2.1-2.fc40.x86_64
                Module mbsync from rpm isync-1.4.4-8.fc40.x86_64
                Stack trace of thread 12415:
                #0  0x000055d33068a967 sync_chans (mbsync + 0xf967)
                #1  0x000055d33068d52e imap_list_store_p2 (mbsync + 0x1252e)
                #2  0x000055d33068d203 done_imap_cmd (mbsync + 0x12203)
                #3  0x000055d330696f61 imap_socket_read (mbsync + 0x1bf61)
                #4  0x000055d330680967 main (mbsync + 0x5967)
                #5  0x00007fb54fa39088 __libc_start_call_main (libc.so.6 + 0x2a088)
                #6  0x00007fb54fa3914b __libc_start_main@@GLIBC_2.34 (libc.so.6 + 0x2a14b)
                #7  0x000055d3306810b5 _start (mbsync + 0x60b5)
                ELF object binary architecture: AMD x86-64

GNU gdb (Fedora Linux) 14.2-3.fc40
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/mbsync...

This GDB supports auto-downloading debuginfo from the following URLs:
  <https://debuginfod.fedoraproject.org/>
Enable debuginfod for this session? (y or [n]) y
Debuginfod has been enabled.
To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit.
Reading symbols from /home/jarkko/.cache/debuginfod_client/3fb7ee1e76d56b433d695891b1affa4e116328b9/debuginfo...
[New LWP 12415]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `mbsync -V kapsi'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000055d33068a967 in sync_chans (mvars=0x7ffef80ee330, ent=<optimized out>) at /usr/src/debug/isync-1.4.4-8.fc40.x86_64/src/main.c:906
906					char *sname = boxes[N] ? boxes[N][sb] : NULL;

Reproducible: Always

Steps to Reproduce:
mbsync -aV
Actual Results:  
SIGSEGV

Expected Results:  
Maildirs are synced.

Happens also with the upstream of isync. I tried this. I marked this as urgent as it prevents me reviewing kernel patches in Linux ;-) I have Mac mini as backup and there mbsync works without issues but it is not a great environment for testing kernel patches.

.mbsyncrc:

 cat .mbsyncrc
IMAPAccount kapsi
Host mail.kapsi.fi
User jjs
PassCmd "pass show imap/mail.kapsi.fi"
SSLType IMAPS

IMAPStore kapsi-remote
Account kapsi

MaildirStore kapsi-local
SubFolders Verbatim
Path ~/.cache/mbsync/kapsi/
Inbox ~/.cache/mbsync/kapsi/INBOX

Channel kapsi
Far :kapsi-remote:
Near :kapsi-local:
Patterns *
Create Both
Expunge Both
SyncState *

Comment 1 Jarkko Sakkinen 2024-07-31 20:46:39 UTC
Did also "SELInux sanity check": "setenforce 0" has no effect on this.

Comment 2 Jarkko Sakkinen 2024-08-01 12:02:39 UTC
Created attachment 2043223 [details]
isync-1.4.4-8.fc40.x86_64

Backtrace with isync-1.4.4-8.fc40.x86_64.

Comment 3 Jarkko Sakkinen 2024-08-01 12:04:05 UTC
Created attachment 2043224 [details]
e70c300f7446 ("permit leading whitespace in INTERNALDATE strings")

Backtrace of upstream commit ID e70c300f7446 ("permit leading whitespace in INTERNALDATE strings").

Comment 4 Jarkko Sakkinen 2024-08-01 15:18:41 UTC
This package is important because it is a niche piece of software BUT at the same time it is widely used by developers working on "core projects" of the Internet, which rely heavily on email.

Comment 5 Jarkko Sakkinen 2024-08-01 18:17:30 UTC
(gdb) print boxes
$1 = {0x5555556c4540, <optimized out>}

I noticed this so I tried:

diff --git a/src/main_sync.c b/src/main_sync.c
index 226e324..afb23ca 100644
--- a/src/main_sync.c
+++ b/src/main_sync.c
@@ -623,6 +623,7 @@ sync_opened( main_vars_t *mvars, int t )
        if (!mvars->chanptr->boxlist && mvars->chan->patterns) {
                mvars->chanptr->boxlist = 2;
                char **boxes[2];
+               __asm__ __volatile__("" :: "m" (boxes));
                boxes[F] = filter_boxes( mvars->boxes[F], mvars->chan->boxes[F], mvars->chan->patterns );
                boxes[N] = filter_boxes( mvars->boxes[N], mvars->chan->boxes[N], mvars->chan->patterns );
                box_ent_t **mboxapp = &mvars->chanptr->boxes;

It literally fixed it! I.e. could this be a GCC bug?

Comment 6 Jarkko Sakkinen 2024-08-01 18:34:46 UTC
I tried compiling with clang (18) now WITHOUT my fix, and that version also works just fine. This should be a stronger evidence of an actual bug in GCC (14). I'll attach my workaround to this bug.

Comment 7 Jarkko Sakkinen 2024-08-01 18:43:35 UTC
Created attachment 2043239 [details]
Workaround for the GCC-14 issue

Commit message can be freely edited whatever suits you.

Comment 8 Michael J Gruber 2024-08-12 12:41:22 UTC
Could this be related to 

ceb0fa9 ("don't try to qsort() NULL array", 2024-07-04)

which is in isync 1.5.0 but not earlier? That version also solves issues during first sync. I've prepared builds here (before prodding fab) in case you'd like to try out:

https://copr.fedorainfracloud.org/coprs/mjg/isync/

Comment 9 Jarkko Sakkinen 2024-08-12 18:45:06 UTC
So in the upstream this patch fixes the issue:  ceb0fa980

It was pointed out the maintainer in the bug: https://sourceforge.net/p/isync/patches/19/

Comment 10 Fabio Alessandro Locati 2024-08-19 20:14:32 UTC
I've created a PR: https://src.fedoraproject.org/rpms/isync/pull-request/5 and uploaded the sources to the side cache. It just needs to be merged :)

Comment 11 Fabio Alessandro Locati 2024-08-19 20:15:40 UTC
*** Bug 2304747 has been marked as a duplicate of this bug. ***

Comment 12 captain.stac 2024-08-26 09:23:35 UTC
(In reply to Michael J Gruber from comment #8)
> Could this be related to 
> 
> ceb0fa9 ("don't try to qsort() NULL array", 2024-07-04)
> 
> which is in isync 1.5.0 but not earlier? That version also solves issues
> during first sync. I've prepared builds here (before prodding fab) in case
> you'd like to try out:
> 
> https://copr.fedorainfracloud.org/coprs/mjg/isync/

Indeed it is related to this. I locally applied the patch on the 1.4.4 and it works fine.

What's the maintainers' preferred strategy regarding this ticket for FC40?

- Upgrade to 1.5.0
- Patch the 1.4.4 (if needed, I can share my patch)

Regards,

Comment 13 Fedora Update System 2024-09-16 20:01:49 UTC
FEDORA-2024-5c1202ba1d (isync-1.5.0-1.fc42) has been submitted as an update to Fedora 42.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-5c1202ba1d

Comment 14 Fedora Update System 2024-09-16 20:05:27 UTC
FEDORA-2024-5c1202ba1d (isync-1.5.0-1.fc42) has been pushed to the Fedora 42 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 15 Fabio Alessandro Locati 2024-09-18 07:40:33 UTC
Problem still occurs in F40 and F41. Please apply the same to also F40 and F41

Comment 16 Fedora Update System 2024-09-18 09:09:59 UTC
FEDORA-2024-1507e7def5 (isync-1.5.0-1.fc41) has been submitted as an update to Fedora 41.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-1507e7def5

Comment 17 Fedora Update System 2024-09-18 09:19:05 UTC
FEDORA-2024-da3e6c873e (isync-1.5.0-1.fc40) has been submitted as an update to Fedora 40.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-da3e6c873e

Comment 18 Fedora Update System 2024-09-18 10:15:56 UTC
FEDORA-2024-b22d84ca47 (isync-1.5.0-1.fc39) has been submitted as an update to Fedora 39.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-b22d84ca47

Comment 19 Fedora Update System 2024-09-19 02:23:14 UTC
FEDORA-2024-da3e6c873e has been pushed to the Fedora 40 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-da3e6c873e`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-da3e6c873e

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 20 Fedora Update System 2024-09-19 03:06:02 UTC
FEDORA-2024-b22d84ca47 has been pushed to the Fedora 39 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-b22d84ca47`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-b22d84ca47

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 21 Fedora Update System 2024-09-19 03:48:58 UTC
FEDORA-2024-1507e7def5 has been pushed to the Fedora 41 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-1507e7def5`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-1507e7def5

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 22 Fedora Update System 2024-09-28 02:32:55 UTC
FEDORA-2024-bfb8f42d46 has been pushed to the Fedora 41 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-bfb8f42d46`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-bfb8f42d46

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 23 Fedora Update System 2024-10-05 22:35:57 UTC
FEDORA-2024-bfb8f42d46 (isync-1.5.0-2.fc41) has been pushed to the Fedora 41 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.