Arnt Gulbrandsen wrote:
>>Program received signal SIGSEGV, Segmentation fault.
>>Mailbox::name (this=0x0) at server/mailbox.cpp:300
>>300       return d->name;
>>(gdb) where
>>#0  Mailbox::name (this=0x0) at server/mailbox.cpp:300
>>#1  0x0809e07e in Command::mailboxName (this=0xf728aa44)
>>     at imap/command.cpp:1223
>>#2  0x0805d933 in Create::parse (this=0xf728aa44)
>>     at imap/handlers/create.cpp:39
>>#3  0x08095438 in IMAP::runCommands (this=0xf72a0344) at imap/imap.cpp:545
>>#4  0x080959b8 in IMAP::react (this=0xf72a0344, e=Connection::Read)
>>     at imap/imap.cpp:215

>A "create" command is run. The parser for that parses a mailbox name.
>The name involved is "inbox", so the mailbox name parser looks for
>the logged-in user's inbox. The logged-in user's inbox is strangely
>null.

>In general, "create inbox" looks like a strange command. Is that what
>the logfile says was sent?

It does.  It looks to be some sort of race condition, where a newly created
INBOX is not found in the internal structures yet.  Possibly created in
the database, but forgetting to update the internal C++ structure, or
waiting to update that for a NOTIFY alert from the database, which comes
(too) late.

>What does the relevant user's inbox look like in the database?

It's always the INBOX of the most recently created user (i.e. the highest
userid).

users:
 243 | [email protected]   | xxxxxxx       |    |       1 | 2147483647 |   251

mailboxes:
 495 | /users/[email protected]/INBOX |   243 |  1 | 1 | 1 | 1 | f

aliases:
 251 |    1347 |     495

addresses:
 1347 |      | xxx  | foo.bar


Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6 Connected: IMAP server 
212.125.129.162:143 connected to client 212.125.129.162:54559, on fd 12 (10 
connections)
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/1 IMAP Command: 00000000 
STARTTLS
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/1 First line: 00000000 
STARTTLS
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6 IMAP::runCommands, 1 commands
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/1 Executing
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6 IMAP::runCommands, 1 commands
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/1 Execution time 0ms
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/1 Finished
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/1 Retired
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/1 00000000 OK done
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6 Negotiating TLS for client 
212.125.129.162:54559
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6 IMAP::runCommands, 0 commands
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/2 IMAP Command: 00000001 
CAPABILITY
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/2 First line: 00000001 
CAPABILITY
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6 IMAP::runCommands, 1 commands
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/2 Executing
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6 IMAP::runCommands, 1 commands
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/2 Execution time 0ms
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/2 Finished
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/2 Retired
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/2 00000001 OK done
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6 IMAP::runCommands, 0 commands
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/3 IMAP Command: 00000002 
AUTHENTICATE
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6 IMAP::runCommands, 1 commands
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/3 Executing
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6 IMAP::runCommands, 1 commands
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/3/1 Waiting for client 
response
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/3/1 Verifying client response
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/3/1 Sent execute for "select 
u.id, u.login, u.secret, u.ldapdn, a.name, a.localpart, a.domain, u.quota, 
al.mailbox as inbox, n.name as parentspace from users u join namespaces n on 
(u.parentspace=n.id) left join aliases al on (u.alias=al.id) left join 
addresses a on (al.address=a.id) where lower(u.login)=lower($1)" 
($1='[email protected]') on backend 3
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6 IMAP::runCommands, 1 commands
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/3/1 Dequeueing query "select 
u.id, u.login, u.secret, u.ldapdn, a.name, a.localpart, a.domain, u.quota, 
al.mailbox as inbox, n.name as parentspace from users u join namespaces n on 
(u.parentspace=n.id) left join aliases al on (u.alias=al.id) left join 
addresses a on (al.address=a.id) where lower(u.login)=lower($1)" 
($1='[email protected]') on backend 3 (with 1 rows)
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/3/1 Authenticated: 
"[email protected]"
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6 Authenticated as [email protected] 
using cram-md5
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6 Changed to authenticated state
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/3 Execution time 2ms
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/3 Finished
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6 IMAP::runCommands, 1 commands
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/3 Retired
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6/3 00000002 OK [CAPABILITY 
IMAP4rev1 ACL ANNOTATE-EXPERIMENT-1 BINARY CATENATE CHILDREN COMPRESS=DEFLATE 
CONDSTORE ENABLE ESEARCH I18NLEVEL=1 ID IDLE LIST-EXTENDED LITERAL+ MOVE 
MULTIAPPEND NAMESPACE QUOTA RIGHTS=ekntx SORT SORT=DISPLAY UIDPLUS UNSELECT 
URLAUTH WITHIN XAOL-MOVE] done
Apr 19 00:53:00 aoxbulk Archiveopteryx: 11017/2/6 IMAP::runCommands, 0 commands
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6/4 IMAP Command: 00000003 LIST
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6/4 First line: 00000003 LIST 
"" *
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6 IMAP::runCommands, 1 commands
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6/4 List /users/[email protected] *
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6/4 Executing
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6 IMAP::runCommands, 1 commands
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6/4 Sent parse/execute for 
"select mb.id, mb.name from mailboxes mb where mb.name ilike $1||'%'||$2 order 
by lower(mb.name)||' '" ($1='/users/[email protected]/',$2='') on backend 3
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6/4 Dequeueing query "select 
mb.id, mb.name from mailboxes mb where mb.name ilike $1||'%'||$2 order by 
lower(mb.name)||' '" ($1='/users/[email protected]/',$2='') on backend 3 (with 1 
rows)
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6/4 Execution time 3ms
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6/4 Finished
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6 IMAP::runCommands, 1 commands
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6/4 Retired
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6/4 00000003 OK done
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6 IMAP::runCommands, 0 commands
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6/5 IMAP Command: 00000004 LIST
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6/5 First line: 00000004 LIST 
"" INBOX
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6 IMAP::runCommands, 1 commands
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6/5 List /users/[email protected] 
INBOX
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6/5 Executing
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6 IMAP::runCommands, 1 commands
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6/5 Sent parse/execute for 
"select mb.id, mb.name from mailboxes mb where mb.name ilike $1 order by 
lower(mb.name)||' '" ($1='/users/[email protected]/INBOX') on backend 3
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6/5 Dequeueing query "select 
mb.id, mb.name from mailboxes mb where mb.name ilike $1 order by 
lower(mb.name)||' '" ($1='/users/[email protected]/INBOX') on backend 3 (with 1 rows)
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6/5 Execution time 3ms
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6/5 Finished
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6 IMAP::runCommands, 1 commands
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6/5 Retired
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6/5 00000004 OK done
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6 IMAP::runCommands, 0 commands
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6/6 IMAP Command: 00000005 
Create
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6/6 First line: 00000005 Create 
INBOX
Apr 19 00:53:01 aoxbulk Archiveopteryx: 11017/2/6 IMAP::runCommands, 1 commands

Debug traces:
Program received signal SIGSEGV, Segmentation fault.
Mailbox::name (this=0x0) at server/mailbox.cpp:300
300         return d->name;
(gdb) p d
Cannot access memory at address 0x0
(gdb) up
#1  0x0809e07e in Command::mailboxName (this=0xf4ebbca4)
    at imap/command.cpp:1223
1223            return u->inbox()->name();
(gdb) ?
Undefined command: "".  Try "help".
(gdb) l
1218        if ( n.endsWith( "/" ) )
1219            n = n.mid( 0, n.length() - 1 );
1220    
1221        User * u = imap()->user();
1222        if ( u && n.lower() == "inbox" ) {
1223            return u->inbox()->name();
1224        }
1225    
1226        MUtf7Codec m;
1227        UString un( m.toUnicode( n ) );
(gdb) p *u
$1 = {<EventHandler> = {<Garbage> = {<No data fields>}, 
    _vptr.EventHandler = 0x8595570, l = 0xf4eba2e4}, d = 0xf3ce9a04}
(gdb) p n
$2 = {<Garbage> = {<No data fields>}, d = 0xf4ebbe04}
(gdb) p n.d
$3 = (EStringData *) 0xf4ebbe04
(gdb) p *n.d
$4 = {<Garbage> = {<No data fields>}, str = 0xf4ebbe10 "INBOX/2/6/6", len = 5, 
  max = 0}
(gdb) p imap()->user();
Invalid character ';' in expression.
(gdb) p imap()->user()
No symbol "imap" in current context.
(gdb) p u->inbox()
$5 = (Mailbox *) 0x0
(gdb) p *u
$6 = {<EventHandler> = {<Garbage> = {<No data fields>}, 
    _vptr.EventHandler = 0x8595570, l = 0xf4eba2e4}, d = 0xf3ce9a04}
(gdb) p u->d
$7 = (UserData *) 0xf3ce9a04
(gdb) p *u->d
$8 = {<Garbage> = {<No data fields>}, login = {<Garbage> = {<No data fields>}, 
    d = 0xf3ce9b04}, secret = {<Garbage> = {<No data fields>}, 
    d = 0xf4ed6804}, ldapdn = {<Garbage> = {<No data fields>}, d = 0x0}, 
  id = 243, inbox = 0x0, inboxId = 495, home = 0xf3db71b4, 
  address = 0xf3db71bc, quota = 2147483647, q = 0xf4ef34d4, result = 0x0, 
  t = 0x0, user = 0xf4eba2a4, error = {<Garbage> = {<No data fields>}, 
    d = 0x0}, state = User::Refreshed, mode = UserData::Refreshing}
(gdb) p ::mailboxes
$9 = (Map<Mailbox> *) 0xf72c2014
(gdb) p *::mailboxes
$10 = {<PatriciaTree<Mailbox>> = {<Garbage> = {<No data fields>}, 
    _vptr.PatriciaTree = 0x81cf9c8, root = 0xf7286524}, <No data fields>}
(gdb) p *::mailboxes->find(245)
Cannot evaluate function -- may be inlined
(gdb) p ::mailboxes->root
$11 = (PatriciaTree<Mailbox>::Node *) 0xf7286524
(gdb) p *::mailboxes->root
$12 = {<Garbage> = {<No data fields>}, zero = 0xf7284364, one = 0xf7288544, 
  parent = 0x0, data = 0x0, length = 23, key = ""}
(gdb) 

-- 
Stephen.

To people that say "I could care less" - well, why don't you?

Reply via email to