[Mimedefang] Mimedefang with postfix. Process memory usage over time.

Robert Theisen trobert at redhat.com
Fri Nov 10 13:18:15 EST 2017


Something that might help.  I noticed that the format of the string in
memory is ...

_ {auth_authen} {auth_author} {auth_ssf} {auth_type} {cert_issuer}
{cert_subject} {cipher} {cipher_bits} {daemon_name} {daemon_port} i
{if_addr} {if_name} j {mail_addr} {mail_host} {mail_mailer}
{tls_version} {verify} {rcpt_addr} {rcpt_host} {rcpt_mailer}


It leads with the _ and does have the curly braces around each item
longer than a single char.
It also terminates at {rcpt_mailer}

The curly braces are not added until the string is processed by
append_macro_value() and then immediately after append_macro_value()
runs, we add another value to dbuf called "client_port".  But client
port does not show up in the memory dump.


    /* Write the standard macros */
    macro = StandardSendmailMacros;
    while (*macro) {
        append_macro_value(&dbuf, ctx, *macro);
        macro++;
    }

    /* Fake client_port: We don't get the macro, but we have the connection
       info cached in our private data area. */
    dbuf_putc(&dbuf, '=');
    append_percent_encoded(&dbuf, "client_port");



Is it possible that during this function ...

static void
append_macro_value(dynamic_buffer *dbuf,
                   SMFICTX *ctx,
                   char *macro)
{
    struct privdata *data;
    char *val;
    char buf[256];

    data = DATA;
    if (!data) return;

    if (*macro && *(macro+1)) {
        /* Longer than 1 char -- use curlies */
        snprintf(buf, sizeof(buf), "{%s}", macro);
        val = smfi_getsymval(ctx, buf);
    } else {
        val = smfi_getsymval(ctx, macro);
    }
    if (!val) return;
    dbuf_putc(dbuf, '=');
    append_percent_encoded(dbuf, macro);
    dbuf_putc(dbuf, ' ');
    append_percent_encoded(dbuf, val);
    dbuf_putc(dbuf, '\n');
}


at         snprintf(buf, sizeof(buf), "{%s}", macro);

that buf[256] is not getting cleaned up even though it is a local
variable that is falling out of scope?

The strike against that theory would be that my memory dump shows that
the "i" and "j" variables are included in that memory chunk.  But the
single character i and j values are never copied to the local buf[256]
variable.

On Fri, Nov 10, 2017 at 12:15 PM, Dianne Skoll <dfs at roaringpenguin.com> wrote:
> On Fri, 10 Nov 2017 10:33:10 -0500
> Robert Theisen <trobert at redhat.com> wrote:
>
> [snip]
>
>> and that macro gets copied to dbuf at line  952
>>
>>     /* Write the standard macros */
>>     macro = StandardSendmailMacros;
>>     while (*macro) {
>>         append_macro_value(&dbuf, ctx, *macro);
>>         macro++;
>>     }
>>
>>
>> Is it possible that that dbuf is not getting freed properly on down
>> the line?
>
> I can't see how.  A bit further down:
>
>     if (data->cmdFD < 0) {
>         dbuf_free(&dbuf);
>         cleanup(ctx);
>         DEBUG_EXIT("envfrom", "SMFIS_TEMPFAIL");
>         return SMFIS_TEMPFAIL;
>     }
>     if (write_dbuf(&dbuf, data->cmdFD, data, "COMMANDS") < 0) {
>         dbuf_free(&dbuf);
>         cleanup(ctx);
>         DEBUG_EXIT("envfrom", "SMFIS_TEMPFAIL");
>         return SMFIS_TEMPFAIL;
>     }
>     dbuf_free(&dbuf);
>
> and there are no branches or returns between the code you posted
> and the code I posted above.  However, I just checked one of our
> busy servers and the mimedefang process is 8GB which seems large.
> I'll investigate to see if I can find a memory leak.
>
> Regards,
>
> Dianne.
> _______________________________________________
> NOTE: If there is a disclaimer or other legal boilerplate in the above
> message, it is NULL AND VOID.  You may ignore it.
>
> Visit http://www.mimedefang.org and http://www.roaringpenguin.com
> MIMEDefang mailing list MIMEDefang at lists.roaringpenguin.com
> http://lists.roaringpenguin.com/mailman/listinfo/mimedefang



More information about the MIMEDefang mailing list