Alas issues remain on FreeBSD, all appears well until I try to to deliver a message with dbmail-deliver.
Perhaps you might have some insight? The segfault happens when creating the
query "INSERT INTO %smessages(mailbox_idnr, physmessage_id,
unique_id,recent_flag, status) VALUES (%lu, %lu, '%s', 1, %d) %s" on line 1280
of dbmail-message.c and nothing appears unusual to me...
(gdb) print frag
$1 = 0x28ccd124 ""
(gdb) print db_params.pfx
$2 = "dbmail_", '\0' <repeats 1016 times>
(gdb) print mailboxid
$3 = 119
(gdb) print dbmail_message_get_physid(self)
$4 = 948591
(gdb) print unique_id
$5 = 0xbfbfe14a "bce1b849b79333815d897b4268200568"
(gdb) print MESSAGE_STATUS_INSERT
$6 = MESSAGE_STATUS_INSERT
(gdb) print frag
$7 = 0x28ccd124 ""
(gdb)
and just before the segfault
Breakpoint 4, db_query (c=0x28ccc370,
q=0x280c21b0 "INSERT INTO %smessages(mailbox_idnr, physmessage_id,
unique_id,recent_flag, status) VALUES (%lu, %lu, '%s', 1, %d) %s") at
dm_db.c:340
340 ResultSet_T r = NULL;
(gdb) next
341 volatile gboolean result = FALSE;
(gdb)
345 va_start(ap, q);
(gdb)
346 va_copy(cp, ap);
(gdb)
347 query = g_strdup_vprintf(q, cp);
(gdb) print q
$1 = 0x280c21b0 "INSERT INTO %smessages(mailbox_idnr, physmessage_id,
unique_id,recent_flag, status) VALUES (%lu, %lu, '%s', 1, %d) %s"
(gdb) print ap
$2 = 0xbfbfde78 "ÈR\016(w"
(gdb) print cp
$3 = 0xbfbfde78 "ÈR\016(w"
(gdb) print db_params.pfx
$4 = "dbmail_", '\0' <repeats 1016 times>
(gdb) nexti
0x28096873 347 query = g_strdup_vprintf(q, cp);
(gdb)
0x28096877 347 query = g_strdup_vprintf(q, cp);
(gdb)
0x2809687a 347 query = g_strdup_vprintf(q, cp);
(gdb)
0x2809687d 347 query = g_strdup_vprintf(q, cp);
(gdb)
Program received signal SIGSEGV, Segmentation fault.
0x28a0ac9c in strlen () from /lib/libc.so.7
I'm still on 32-bit with gcc 4.2.1. After using the attached patches, all
compiles well though there are the expected warning: format '%lu' expects type
'long unsigned int', but argument 3 has type 'uint64_t'.
dbmail-imapd appears to run successfully though has only minimal testing so
far.
Any insight appreciated,
Alan
extra-patch-acinclude.m4
Description: application/m4
patch-acinclude.m4
Description: application/m4
--- src/clientbase.c.orig
+++ src/clientbase.c
@@ -159,7 +159,7 @@ ClientBase_T * client_init(client_sock *c)
} else {
/* server-side */
TRACE(TRACE_DEBUG,"saddr [%p] sa_family [%d] len [%d]", c->saddr, c->saddr->sa_family, c->saddr_len);
- if ((serr = getnameinfo(c->saddr, c->saddr_len, client->dst_ip, NI_MAXHOST, client->dst_port, NI_MAXSERV,
+ if ((serr = getnameinfo(c->saddr, c->saddr->sa_len, client->dst_ip, NI_MAXHOST, client->dst_port, NI_MAXSERV,
NI_NUMERICHOST | NI_NUMERICSERV))) {
TRACE(TRACE_INFO, "getnameinfo::error [%s]", gai_strerror(serr));
}
@@ -167,13 +167,13 @@ ClientBase_T * client_init(client_sock *c)
/* client-side */
TRACE(TRACE_DEBUG,"caddr [%p] sa_family [%d] len [%d]", c->caddr, c->caddr->sa_family, c->caddr_len);
- if ((serr = getnameinfo(c->caddr, c->caddr_len, client->src_ip, NI_MAXHOST, client->src_port, NI_MAXSERV,
+ if ((serr = getnameinfo(c->caddr, c->caddr->sa_len, client->src_ip, NI_MAXHOST, client->src_port, NI_MAXSERV,
NI_NUMERICHOST | NI_NUMERICSERV))) {
TRACE(TRACE_EMERG, "getnameinfo:error [%s]", gai_strerror(serr));
}
if (server_conf->resolveIP) {
- if ((serr = getnameinfo(c->caddr, c->caddr_len, client->clientname, NI_MAXHOST, NULL, 0, NI_NAMEREQD))) {
+ if ((serr = getnameinfo(c->caddr, c->caddr->sa_len, client->clientname, NI_MAXHOST, NULL, 0, NI_NAMEREQD))) {
TRACE(TRACE_INFO, "getnameinfo:error [%s]", gai_strerror(serr));
}
--- src/dbmail.h.in.orig
+++ src/dbmail.h.in
@@ -83,8 +83,14 @@
#include <mhash.h>
#include <sys/queue.h>
#include <event2/event.h>
+#include <event2/event_compat.h>
#include <event2/thread.h>
-#include <evhttp.h>
+#include <event2/http.h>
+#include <event2/http_struct.h>
+#include <event2/http_compat.h>
+#include <event2/buffer.h>
+#include <event2/buffer_compat.h>
+#include <event2/keyvalq_struct.h>
#include <math.h>
#include <openssl/ssl.h>
@@ -154,6 +160,11 @@
#include <endian.h>
#endif
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+
#define GETCONFIGVALUE(key, sect, var) \
config_get_value(key, sect, var); \
if (strlen(var) > 0) \
Script started on Tue Jun 4 16:15:18 2013 gdb -d /usr/home/alan/projects/dbmail/work/dbmail-3.0.2/src /usr/home/alan/projects/dbmail/work/dbmail-3.0.2/src/.libs/dbmail-deliver GNU gdb 6.1.1 [FreeBSD] Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-marcel-freebsd"... (gdb) set args -d [email protected] (gdb) run Starting program: /usr/home/alan/projects/dbmail/work/dbmail-3.0.2/src/.libs/dbmail-deliver -d [email protected] [New LWP 100053] [New Thread 28c04300 (LWP 100053/dbmail-deliver)] [New Thread 28c04c00 (LWP 100560/dbmail-deliver)] hello ^D Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 28c04300 (LWP 100053/dbmail-deliver)] 0x28a0ac9c in strlen () from /lib/libc.so.7 (gdb) bt #0 0x28a0ac9c in strlen () from /lib/libc.so.7 #1 0x28a02b3a in gettimeofday () from /lib/libc.so.7 #2 0x000e7961 in ?? () #3 0x00000001 in ?? () #4 0xbfbfd750 in ?? () #5 0xbfbfd798 in ?? () #6 0x2807141c in .dynsym () from /usr/local/lib/dbmail/libdbmail.so.0 #7 0xbfbfd734 in ?? () #8 0x28061dc4 in ?? () from /libexec/ld-elf.so.1 #9 0x00000301 in ?? () #10 0x28066200 in ?? () #11 0xbfbfd774 in ?? () #12 0x2805227d in dlclose () from /libexec/ld-elf.so.1 #13 0x289ab08f in vasprintf_l () from /lib/libc.so.7 #14 0x289ab14d in vasprintf () from /lib/libc.so.7 #15 0x2833e627 in g_vasprintf () from /usr/local/lib/libglib-2.0.so.0 #16 0x2831c7e2 in g_strdup_vprintf () from /usr/local/lib/libglib-2.0.so.0 #17 0x28096882 in db_query (c=0x28ccc370, q=0x280c21b0 "INSERT INTO %smessages(mailbox_idnr, physmessage_id, unique_id,recent_flag, status) VALUES (%lu, %lu, '%s', 1, %d) %s") at dm_db.c:347 #18 0x280827c2 in _message_insert (self=0x28c80330, user_idnr=12, mailbox=0x280c2033 "INBOX", unique_id=0xbfbfe15a "bce1b849b79333815d897b4268200568") at dbmail-message.c:1280 #19 0x28082147 in dbmail_message_store (self=0x28c80330) at dbmail-message.c:1146 #20 0x28087640 in insert_messages (message=0x28c80330, dsnusers=0x28c10030) at dbmail-message.c:2641 #21 0x08049fa5 in main (argc=3, argv=0xbfbfeb74) at main.c:328 (gdb) break insert_messages Breakpoint 1 at 0x28087627: file dbmail-message.c, line 2633. (gdb) run The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: /usr/home/alan/projects/dbmail/work/dbmail-3.0.2/src/.libs/dbmail-deliver -d [email protected] [New LWP 100254] [New Thread 28c04300 (LWP 100254/dbmail-deliver)] [New Thread 28c04c00 (LWP 100566/dbmail-deliver)] hello ^D[Switching to Thread 28c04300 (LWP 100254/dbmail-deliver)] Breakpoint 1, insert_messages (message=0x28c80330, dsnusers=0x28c10030) at dbmail-message.c:2633 2633 int result=0; (gdb) next 2635 gboolean quota_softfail = FALSE; (gdb) 2641 if ((result = dbmail_message_store(message)) == DM_EQUERY) { (gdb) Program received signal SIGSEGV, Segmentation fault. 0x28a0ac9c in strlen () from /lib/libc.so.7 (gdb) break dbmail_message_so tore Breakpoint 2 at 0x28082075: file dbmail-message.c, line 1133. (gdb) run The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: /usr/home/alan/projects/dbmail/work/dbmail-3.0.2/src/.libs/dbmail-deliver -d [email protected] [New LWP 100193] [New Thread 28c04300 (LWP 100193/dbmail-deliver)] [New Thread 28c04c00 (LWP 100572/dbmail-deliver)] hello ^D[Switching to Thread 28c04300 (LWP 100193/dbmail-deliver)] Breakpoint 1, insert_messages (message=0x28c80330, dsnusers=0x28c10030) at dbmail-message.c:2633 2633 int result=0; (gdb) continue Continuing. Breakpoint 2, dbmail_message_store (self=0x28c80330) at dbmail-message.c:1133 1133 int res = 0, i = 1, retry = 10, delay = 200; (gdb) next 1134 int step = 0; (gdb) 1136 if (! auth_user_exists(DBMAIL_DELIVERY_USERNAME, &user_idnr)) { (gdb) 1141 create_unique_id(unique_id, user_idnr); (gdb) 1143 while (i++ < retry) { (gdb) 1144 if (step == 0) { (gdb) 1146 if(_message_insert(self, user_idnr, DBMAIL_TEMPMBOX, unique_id) < 0) { (gdb) Program received signal SIGSEGV, Segmentation fault. 0x28a0ac9c in strlen () from /lib/libc.so.7 (gdb) break _message_insert Breakpoint 3 at 0x28082549: file dbmail-message.c, line 1247. (gdb) run The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: /usr/home/alan/projects/dbmail/work/dbmail-3.0.2/src/.libs/dbmail-deliver -d [email protected] [New LWP 100061] [New Thread 28c04300 (LWP 100061/dbmail-deliver)] [New Thread 28c04c00 (LWP 100578/dbmail-deliver)] hello ^D[Switching to Thread 28c04300 (LWP 100061/dbmail-deliver)] Breakpoint 1, insert_messages (message=0x28c80330, dsnusers=0x28c10030) at dbmail-message.c:2633 2633 int result=0; (gdb) continue Continuing. Breakpoint 2, dbmail_message_store (self=0x28c80330) at dbmail-message.c:1133 1133 int res = 0, i = 1, retry = 10, delay = 200; (gdb) Continuing. Breakpoint 3, _message_insert (self=0x28c80330, user_idnr=12, mailbox=0x280c2033 "INBOX", unique_id=0xbfbfe15a "bce1b849b79333815d897b4268200568") at dbmail-message.c:1247 1247 char *frag = NULL; (gdb) next 1249 volatile int t = 0; (gdb) 1251 assert(unique_id); (gdb) 1252 assert(mailbox); (gdb) 1254 if (db_find_create_mailbox(mailbox, BOX_DEFAULT, user_idnr, &mailboxid) == -1) (gdb) 1257 if (mailboxid == 0) { (gdb) 1265 c = db_con_get(); (gdb) 1266 TRY (gdb) 1267 db_begin_transaction(c); (gdb) 1268 insert_physmessage(self, c); (gdb) 1270 if (db_params.db_driver == DM_DRIVER_ORACLE) { (gdb) 1279 frag = db_returning("message_idnr"); (gdb) 1280 r = db_query(c, "INSERT INTO " (gdb) Program received signal SIGSEGV, Segmentation fault. 0x28a0ac9c in strlen () from /lib/libc.so.7 (gdb) break db_query Breakpoint 4 at 0x28096856: file dm_db.c, line 340. (gdb) run The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: /usr/home/alan/projects/dbmail/work/dbmail-3.0.2/src/.libs/dbmail-deliver -d [email protected] [New LWP 100254] [New Thread 28c04300 (LWP 100254/dbmail-deliver)] [New Thread 28c04c00 (LWP 100584/dbmail-deliver)] [Switching to Thread 28c04300 (LWP 100254/dbmail-deliver)] Breakpoint 4, db_query (c=0x28ccc370, q=0x280cb720 "SELECT 1=1 FROM %s%s LIMIT 1 OFFSET 0") at dm_db.c:340 340 ResultSet_T r = NULL; (gdb) continue Continuing. Breakpoint 4, db_query (c=0x28ccc370, q=0x280cb720 "SELECT 1=1 FROM %s%s LIMIT 1 OFFSET 0") at dm_db.c:340 340 ResultSet_T r = NULL; (gdb) Continuing. Breakpoint 4, db_query (c=0x28ccc370, q=0x280cb720 "SELECT 1=1 FROM %s%s LIMIT 1 OFFSET 0") at dm_db.c:340 340 ResultSet_T r = NULL; (gdb) Continuing. Breakpoint 4, db_query (c=0x28ccc370, q=0x280cb720 "SELECT 1=1 FROM %s%s LIMIT 1 OFFSET 0") at dm_db.c:340 340 ResultSet_T r = NULL; (gdb) Continuing. Breakpoint 4, db_query (c=0x28ccc370, q=0x280cb720 "SELECT 1=1 FROM %s%s LIMIT 1 OFFSET 0") at dm_db.c:340 340 ResultSet_T r = NULL; (gdb) Continuing. hello ^D Breakpoint 1, insert_messages (message=0x28c80330, dsnusers=0x28c10030) at dbmail-message.c:2633 2633 int result=0; (gdb) Continuing. Breakpoint 2, dbmail_message_store (self=0x28c80330) at dbmail-message.c:1133 1133 int res = 0, i = 1, retry = 10, delay = 200; (gdb) Continuing. Breakpoint 3, _message_insert (self=0x28c80330, user_idnr=12, mailbox=0x280c2033 "INBOX", unique_id=0xbfbfe15a "bce1b849b79333815d897b4268200568") at dbmail-message.c:1247 1247 char *frag = NULL; (gdb) Continuing. Breakpoint 4, db_query (c=0x28ccc370, q=0x280c2068 "INSERT INTO %sphysmessage (internal_date) VALUES (%s) %s") at dm_db.c:340 340 ResultSet_T r = NULL; (gdb) Continuing. Breakpoint 4, db_query (c=0x28ccc370, q=0x280c21b0 "INSERT INTO %smessages(mailbox_idnr, physmessage_id, unique_id,recent_flag, status) VALUES (%lu, %lu, '%s', 1, %d) %s") at dm_db.c:340 340 ResultSet_T r = NULL; (gdb) next 341 volatile gboolean result = FALSE; (gdb) 345 va_start(ap, q); (gdb) 346 va_copy(cp, ap); (gdb) 347 query = g_strdup_vprintf(q, cp); (gdb) print q $1 = 0x280c21b0 "INSERT INTO %smessages(mailbox_idnr, physmessage_id, unique_id,recent_flag, status) VALUES (%lu, %lu, '%s', 1, %d) %s" (gdb) print ap $2 = 0xbfbfde78 "�R\016(w" (gdb) print cp $3 = 0xbfbfde78 "�R\016(w" (gdb) print db_params.pfx $4 = "dbmail_", '\0' <repeats 1016 times> (gdb) nexti 0x28096873 347 query = g_strdup_vprintf(q, cp); (gdb) 0x28096877 347 query = g_strdup_vprintf(q, cp); (gdb) 0x2809687a 347 query = g_strdup_vprintf(q, cp); (gdb) 0x2809687d 347 query = g_strdup_vprintf(q, cp); (gdb) Program received signal SIGSEGV, Segmentation fault. 0x28a0ac9c in strlen () from /lib/libc.so.7 (gdb) bt #0 0x28a0ac9c in strlen () from /lib/libc.so.7 #1 0x28a02b3a in gettimeofday () from /lib/libc.so.7 #2 0x000e7965 in ?? () #3 0x00000001 in ?? () #4 0xbfbfd750 in ?? () #5 0xbfbfd798 in ?? () #6 0x2807141c in .dynsym () from /usr/local/lib/dbmail/libdbmail.so.0 #7 0xbfbfd734 in ?? () #8 0x28061dc4 in ?? () from /libexec/ld-elf.so.1 #9 0x00000301 in ?? () #10 0x28066200 in ?? () #11 0xbfbfd774 in ?? () #12 0x2805227d in dlclose () from /libexec/ld-elf.so.1 #13 0x289ab08f in vasprintf_l () from /lib/libc.so.7 #14 0x289ab14d in vasprintf () from /lib/libc.so.7 #15 0x2833e627 in g_vasprintf () from /usr/local/lib/libglib-2.0.so.0 #16 0x2831c7e2 in g_strdup_vprintf () from /usr/local/lib/libglib-2.0.so.0 #17 0x28096882 in db_query (c=0x28ccc370, q=0x280c21b0 "INSERT INTO %smessages(mailbox_idnr, physmessage_id, unique_id,recent_flag, status) VALUES (%lu, %lu, '%s', 1, %d) %s") at dm_db.c:347 #18 0x280827c2 in _message_insert (self=0x28c80330, user_idnr=12, mailbox=0x280c2033 "INBOX", unique_id=0xbfbfe15a "bce1b849b79333815d897b4268200568") at dbmail-message.c:1280 #19 0x28082147 in dbmail_message_store (self=0x28c80330) at dbmail-message.c:1146 #20 0x28087640 in insert_messages (message=0x28c80330, dsnusers=0x28c10030) at dbmail-message.c:2641 #21 0x08049fa5 in main (argc=3, argv=0xbfbfeb74) at main.c:328 (gdb) quit The program is running. Exit anyway? (y or n) y Script done on Tue Jun 4 16:19:56 2013
_______________________________________________ Dbmail-dev mailing list [email protected] http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail-dev
