My immediate attention is at #5 0x0804c81a in trace (level=5,
formatstring=0x807119a "%s,%s: executing query [%s]") at debug.c:93

Line 93 is a call to vsyslog.
My guess is that argp is null or even worse, uninitialised.

Try adding an if(argp) before using argp like this:

void trace (int level, char *formatstring, ...)
{
   va_list argp;

   va_start(argp, formatstring);

   if (level <= TRACE_LEVEL)
     {
       if (TRACE_VERBOSE != 0)
       {
         vfprintf (err_out_stream, formatstring, argp);
         if (formatstring[strlen(formatstring)]!='\n')
           fprintf (err_out_stream,"\n");
       }
       if (TRACE_TO_SYSLOG != 0)
         {
           if (formatstring[strlen(formatstring)]=='\n')
             formatstring[strlen(formatstring)]='\0';
           if (level <= TRACE_WARNING)
             {
               /* set LOG_ALERT at warnings */
                   if(argp)
                  vsyslog (LOG_ALERT, formatstring, argp);
             }
           else
             if(argp)
               vsyslog (LOG_NOTICE, formatstring, argp);
         }
       if(argp)
         va_end(argp);
     }

   /* very big fatal error
    * bailout */

   if (level == TRACE_FATAL)
     exit(EXIT_CODE);

   if (level == TRACE_STOP)
     exit(EXIT_CODE);
}

Regards,

John
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Ilja Booij
Sent: Friday, January 30, 2004 8:57 PM
To: dbmail@dbmail.org; dbmail-dev@dbmail.org
Subject: Re: [Dbmail] DBmail 2.x, PostgreSQL, IMAP




Sandino Araico Sanchez wrote:
> [EMAIL PROTECTED] root] gdb --pid=361
<snip gdb preamble
> (gdb) continue
> Continuing.
> 
> Program received signal SIGSEGV, Segmentation fault. 0x400b90f0 in 
> malloc_consolidate () from /lib/libc.so.6
> (gdb) bt
> #0 0x400b90f0 in malloc_consolidate () from /lib/libc.so.6
> #1 0x400b898e in _int_malloc () from /lib/libc.so.6
> #2 0x400b7bc1 in malloc () from /lib/libc.so.6
> #3 0x400ada81 in open_memstream () from /lib/libc.so.6
> #4 0x40116d92 in vsyslog () from /lib/libc.so.6
> #5 0x0804c81a in trace (level=5,
> formatstring=0x807119a "%s,%s: executing query [%s]") at debug.c:93 #6

> 0x080681ab in db_query ( the_query=0x80799c0 "SELECT no_select FROM 
> mailboxes WHERE mailbox_idnr = '1'") at dbpgsql.c:217
> #7 0x080635f1 in db_isselectable (mailbox_idnr=0) at db.c:2476
> #8 0x08054da1 in _ic_list (tag=0xbfffc640 "5", args=0x807a2a0, 
> ci=0x8079dc0)
> at imapcommands.c:1300
> #9 0x0804c287 in IMAPClientHandler (ci=0x8079dc0) at imap4.c:342
> #10 0x0804bbcd in PerformChildTask (info=0xbfffeee0) at
serverchild.c:341
> #11 0x0804b8cf in CreateChild (info=0x0) at serverchild.c:232
> #12 0x0804b1ad in StartServer (conf=0xbfffef50) at server.c:141
> #13 0x0805d986 in main (argc=1, argv=0x0) at imapd.c:128
> (gdb)

This seems to suggest a bug in the trace() function in debug.c Problem
is.. I can't seem to find what's wrong. For clarity, I'll print 
the function below. Can anybody find anything that's wrong?

void trace (int level, char *formatstring, ...)
{
   va_list argp;

   va_start(argp, formatstring);

   if (level <= TRACE_LEVEL)
     {
       if (TRACE_VERBOSE != 0)
       {
         vfprintf (err_out_stream, formatstring, argp);
         if (formatstring[strlen(formatstring)]!='\n')
           fprintf (err_out_stream,"\n");
       }
       if (TRACE_TO_SYSLOG != 0)
         {
           if (formatstring[strlen(formatstring)]=='\n')
             formatstring[strlen(formatstring)]='\0';
           if (level <= TRACE_WARNING)
             {
               /* set LOG_ALERT at warnings */
               vsyslog (LOG_ALERT, formatstring, argp);
             }
           else
             vsyslog (LOG_NOTICE, formatstring, argp);
         }
       va_end(argp);
     }

   /* very big fatal error
    * bailout */

   if (level == TRACE_FATAL)
     exit(EXIT_CODE);

   if (level == TRACE_STOP)
     exit(EXIT_CODE);
}

Currently, I'm a bit lost here..

Sandino, could you try recompiling with TRACE_TO_SYSLOG (in debug.c) set

to 0 (zero), and running again. Maybe there's an error earlier in the 
code, which will show up in a different place when not tracing to
syslog.

BTW, I'm also sending this to dbmail-dev

Ilja


-- 
IC&S
Stadhouderslaan 57
3583 JD Utrecht

PGP-key:
http://www.ic-s.nl/keys/ilja.txt

_______________________________________________
Dbmail mailing list
Dbmail@dbmail.org https://mailman.fastxs.nl/mailman/listinfo/dbmail

Reply via email to