[tpop3d-discuss] Memory leak?

Marc Lewis marc at blarg.net
Wed, 8 May 2002 10:12:52 -0700


On Wed, May 08, 2002 at 11:40:56AM +0100, Chris Lightfoot wrote:
> On Wed, May 08, 2002 at 01:19:58AM -0700, Marc Lewis wrote:
> > On Wed, May 08, 2002 at 09:02:47AM +0100, Chris Lightfoot wrote:
> > > On Tue, May 07, 2002 at 03:46:27PM -0700, Marc Lewis wrote:
> > > > 
> > > > We've been running tpop3d for about a week now, and find it to be
> > > > excellent piece of software.
> > > > 
> > > > It has crashed on us twice, though, and I believe it may be because of a
> > > > memory leak.
>     [...]
> > > > Suggestions/comments?
> > > 
> > > Can you tell me more about the configuration-- what
> > > settings do you have in the config file? How is PAM
> > > configured? 
> > 
> > Very straightforward:
> > 
> > listen-address: 0.0.0.0:110
> > 
> > max-children: 200
> > strip-domain: yes
> > mailbox: maildir:$(home)/Maildir
> > auth-pam-enable: yes
> > auth-pam-facility: tpop3d
> > 
> > timeout-seconds: 600
> 
> OK, this is fine....
> 
> > The contents of /etc/pam.d/tpop3d:
> > 
> > auth       required     pam_nologin.so
> > auth       required     pam_stack.so service=system-auth
> > account    required     pam_stack.so service=system-auth
> > session    required     pam_stack.so service=system-auth
> > 
> > 
> > The PAM/LDAP part is a bit trickier, but not by much.  It is the basic
> > stuff from www.padl.com for authentication with 'ldap' added into
> > /etc/nsswitch.conf for passwd, shadow and group.  It should be completely
> > transparent to tpop3d as it is to Courier (the IMAP server we are using)
> > and to SASL (for SMTP authentication with Postfix).
> 
> OK.
> 
> > > The fact that the parent process is growing in size
> > > suggests a leak in the authentication code. I can't
> > > reproduce what you're seeing here, but I don't have any of
> > > the PAM LDAP stuff. I don't think that there's a problem
> > > with the mmap code.
> > > 
> > > What does the output of cat /proc/<tpop3d PID>/maps
> > > indicate?
> > 
> > Before restarting it:
> > 
> > # cat /proc/31761/maps
>     [...]
> > After restarting it:
>     [...]
> > # cat /proc/18301/maps
>     [...]
> 
> These are both essentially the same, which is what I
> expect.
> 
> > Let me know if there is any other information that you would like.
> 
> I've attached a trivial test of the PAM code, pamtest.c.
> Could you replace `user' and `password' at the end with a
> valid username and password, compile it with
>     cc -o pamtest -lpam -ldl pamtest.c
> and see whether it leaks memory when you run it?

Yes, it does.  When first started:

# ps auxw | grep pamtest
root     27063  8.5  0.1  4412 1904 pts/1    R    09:28   0:00 ./pamtest

After about a minute of running:

# ps auxw | grep pamtest
root     27810 12.5  0.7  9748 7236 pts/1    S    09:28   0:07 ./pamtest


I may try configuring it so it uses auth-ldap and bypasses PAM, but that
doesn't seem like a good long term fix since we're using PAM to keep things
uniform.

> Also, can you tell me more about the crashes you've
> experienced -- in particular, is there any useful
> information in the logs?

Nothing.  Things just stop.  Also, I don't know if anyone else has seen
this, but it is a bit bizarre.  After first starting up tpop3d, it logs
things to /var/log/maillog as one would expect.  After running for a while,
though, suddenly it will start up in /var/log/messages and the mail log
entries will stop.  It is very, very strange and the only application that
shifts from one log to another.  It could be a symptom of the other
problem, but I thought I would mention it anyway.

Thanks.

 - Marc

-- 
Marc Lewis
Network Administrator
Blarg! Online Services, Inc.
http://www.blarg.net/~marc