assert()
David Carter
dpc22 at cam.ac.uk
Wed Jan 16 09:41:04 EST 2008
Cyrus seems to be fairly inconsistent in its use of assert() tests. 37 of
the .c files use the builtin Cyrus assert(), defined by:
#include "assert.h"
While 23 .c source files use the system assert() macro, defined by:
#include <assert.h>
The system assert() function sends a message to stderr and then calls
abort(). This sends the error verbatim to an IMAP/POP/LMTP client:
. LIST "" *
imapd: cyrusdb_skiplist.c:913: myfetch: Assertion `2 + 2 == 5' failed.
Nothing is sent to syslog.
In contrast the internal assert() sends the error to fatal(). IMAP, POP
and LMTP daemons would send more appropriate error back to the clients:
. LIST "" *
* BYE Fatal error: Internal error: assertion failed:
cyrusdb_skiplist.c: 913: 2 + 2 == 5
MAIL FROM:<dpc22>
250 2.1.0 ok
RCPT TO:<dpc22>
421 4.3.0 lmtpd: Internal error: assertion failed:
cyrusdb_skiplist.c: 913: 2 + 2 == 5
The error text is also sent to syslog() before a proper shut_down().
Here is a simple patch to change all of the '#include <assert.h>' into
'#include "assert.h"':
http://www-uxsup.csx.cam.ac.uk/~dpc22/cyrus/patches/2.3cvs/assert.patch
--
David Carter Email: David.Carter at ucs.cam.ac.uk
University Computing Service, Phone: (01223) 334502
New Museums Site, Pembroke Street, Fax: (01223) 334679
Cambridge UK. CB2 3QH.
More information about the Cyrus-devel
mailing list