Closed brong closed 14 years ago
From: Alex Deiter
Hi,
Cyrus IMAP 2.3.6 have a bug on 64bit BIG-endian arch:
program terminated by signal BUS (invalid address alignment) Current function is mailbox_read_index_header 946 ntohll(((bit64 )(mailbox->index_base+OFFSET_HIGHESTMODSEQ_64))); (dbx) where =>[1] mailbox_read_index_header(mailbox = 0xffffffff7fffd858), line 946 in "mailbox.c" [2] mailbox_open_index(mailbox = 0xffffffff7fffd858), line 675 in "mailbox.c" [3] cmd_select(tag = 0x1002ac920 "s", cmd = 0x1002ac9a0 "Select", name = 0x1002aca20 "INBOX"), line 3388 in "imapd.c" [4] cmdloop(), line 1650 in "imapd.c" [5] service_main(argc = 1, argv = 0x100299ba0, envp = 0xffffffff7ffffcb8), line 789 in "imapd.c" [6] main(argc = 1, argv = 0xffffffff7ffffca8, envp = 0xffffffff7ffffcb8), line 532 in "service.c"
Thanks!
Attachment-Id: 452 From: Ken Murchison Type: text/plain File: 64bit_alignment.diff
64bit alignment patch
From: Ken Murchison
Which compiler are you using? I can't reproduce with gcc on Solaris 8
From: Alex Deiter
i'm used Sun Studio 11 on Solaris 9.
This patch broken build:
cc -c -I.. -I./../lib -I./../sieve -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/local/include -DKRB5_HEIMDAL -I/usr/local/include -DHAVE_CONFIG_H -xarch=v9 -xO5 -xspace -D_LARGEFILE64_SOURCE -D_REENTRANT -I/usr/local/include -KPIC -DPIC \ index.c "mailbox.h", line 112: warning: unnamed struct member "index.c", line 236: improper member use: index_base "index.c", line 1951: warning: argument #6 is incompatible with prototype: prototype: pointer to int : "./../lib/charset.h", line 75 argument : pointer to unsigned int "index.c", line 3533: warning: argument #2 is incompatible with prototype: prototype: pointer to const char : "./../lib/message_uuid.h", line 61 argument : pointer to unsigned char cc: acomp failed for index.c gmake[1]: [index.o] Error 2 gmake[1]: Leaving directory `/home/devel/build/mail/cyrus-imapd/64/cyrus-imapd-2.3.7/imap' gmake: [all] Error 1 *** Error code 2
Stop.
Thanks a lot!
From: James Goodlet
Hi,
I've just tripped across this issue too. We're running 2.2.13 on Solaris 10 (64 bit, sparc, gcc 4.0.3, now
gcc 4.1.2), and attempting to migrate to 2.3.8. We're getting bus errors in imapd in
mailbox_read_index_header as it tries to read mailbox->highestmodseq from an existing header file.
The back trace is:
name=0x15ea00 "inbox") at imapd.c:3451
at imapd.c:797
argv=<value optimized out>, envp=0xffbff89c) at service.c:539
and the specific line which throws the error is (on mailbox.c:947):
946 #ifdef HAVE_LONG_LONG_INT 947 mailbox->highestmodseq = 948 ntohll(((bit64 )(mailbox->index_base+OFFSET_HIGHESTMODSEQ_64))); 949 #else
The bus error is caused by the attempt to read a 64 bit value from a non-64 bit aligned address.
index_base is fine with a value of 0xfe8d0000, but the problem comes because
OFFSET_HIGHESTMODSEQ_64 is defined to be 68, hence the resulting address doesn't align on a 64 bit
boundary (i.e. mod 64 will equal 32 not 0).
Reading around, I found this similar bug report for Dovecot
<http://www.dovecot.org/list/dovecot/2005-January/005925.html>
which has a useful summary and link to a discussion on a GCC bugs forum and suggests strongly that the problem is made apparent when gcc's optimisation is turned on.
Whilst I haven't tested your proposed patch, I don't see that it will fix the problem of the OFFSET_HIGHESTMODSEQ_64 offset causing the non-64 bit aligned addresses. I'll put together a patch (based on the approach in the Dovecot message), since I both need to go to 2.3.8 and to get benefit from the "64 bit" quota patch. I doubt my patch will be very elegant, but I'll submit it here when I've completed it, which should be in a couple of hours.
James
For reference, here's the dump of *mailbox at the point of the crash:
(gdb) p *mailbox $3 = { header_fd = 10, index_fd = 13, cache_fd = 14, header_base = 0xfed90000 "?\002\213\rCyrus mailbox header\n\"The best thing about this system was that it had lots of goals.\"\n\t--Jim Morris on Andrew\nuser.test\t14292238454f6335\nNotJunk $NotJunk JunkRecorded Forwarded MessageJunkMailLev"..., header_len = 253, index_base = 0xfe8d0000 "", index_len = 16384, cache_base = 0xfe8b0000 "", cache_len = 65536, cache_size = 50656, header_lock_count = 0, index_lock_count = 0, seen_lock_count = 0, pop_lock_count = 0, header_ino = 11504296, index_mtime = 1174669417, index_ino = 10154440, index_size = 3616, name = 0x156ff0 "user.test", path = 0x15ea70 "/tmp/mailstoretmp/spool1/user/test", mpath = 0x0, acl = 0x157008 "test\tlrswipcda\t", myrights = 2047, uniqueid = 0x159a18 "14292238454f6335", flagname = {0x156a98 "NotJunk", 0x157038 "$NotJunk", 0x157050 "JunkRecorded", 0x157068 "Forwarded", 0x159a38 "MessageJunkMailLevel", 0x157080 "$Forwarded", 0x156aa8 "Junk", 0x156ab8 "$Junk", 0x157098 "Redirected", 0x0 <repeats 119 times>}, generation_no = 15, format = 0, minor_version = 9, start_offset = 96, record_size = 80, exists = 44, last_appenddate = 1174291915, last_uid = 4416, quota_mailbox_used = 472087, pop3_last_login = 0, uidvalidity = 0, deleted = 0, answered = 0, flagged = 0, dirty = 0, options = 0, leaked_cache_records = 0, highestmodseq = 0, spares = {0, 0, 0, 0}, quota = { root = 0x157020 "user.test", used = 0, limit = 0 }, examining = 1, keepingseen = 0, allseen = 0, recentuid = 0 }
Attachment-Id: 534 From: James Goodlet Type: text/plain File: cyrus-imapd-2.3.8-highestmodseq-64bit-alignment-patch
highestmodseq 64bit alignment patch
Attachment-Id: 561 From: Ken Murchison Type: text/plain File: 64bit_alignment.patch
alternate highestmodeseq 64bit alignment patch
From: James Goodlet
Yes, that works fine. Built, installed, tested on Solaris 10 on sparcv9 architecture running with 64 bit kernel space, and 32/64-bit user space. Cyrus IMAPD is built as a 32 bit application using gcc 4.1.2. The 64 bit extensions are working fine now.
Thanks for the prompt response, and keep up the good work.
James
From: Ken Murchison
Applied alternate patch to CVS
From: Alex Deiter Bugzilla-Id: 2861 Version: 2.3.x Owner: Ken Murchison