[Exim] Memory problems with partial lookups

Top Page
Delete this message
Reply to this message
Author: Hubbard, Matt R W
Date:  
To: exim-users
Subject: [Exim] Memory problems with partial lookups
Hi,

I've been trying to track down a problem I've been experiencing with excessive memory usage. I duly acknowledge that this only happens under unusual circumstances with a specific configuration.

You can send a message with 10000 email addresses in the To headers and the memory usage for the process will only be between 1 and 2 MB.

You can put in re-writing rules that match every address and do standard look ups, the memory usage won't change appreciably.

However, if you make that lookup a "partial" one, and the look up succeeds for the addresses, memory is used that isn't freed afterwards. With the 10000 addresses, the memory usage can exceed 2GB.

From a strings of a core, this unfreed memory appears to be, for each matching address: the filename for the partial lookup, the domain 5 times and the localpart@domain 4 times.


I believe this may have something to do with the expand_nstrings being overwritten specifically during "partial lookups" search.c:773. I think it may be that the string pointers in expand_nstring[x] are over written without the memory the original pointer referenced being freed.

Though this wouldn't explain why the filename is left as well, I'm not getting anywhere fast in my attempts to debug it.


A simple test case would be the following rewrite rule:
    *@* \
    $1@${lookup{${lc:$2}}partial-lsearch{ETCDIR/domain-rewrites}{$value}fail} \    FTbcfrt


Where the only thing in the file ETCDIR/domain-rewrites is:
test.example:    test.example


And then push through a message with multiple "random@???" email addresses in the To header.

Cheers,
Matt.