Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Kernel memory leak in opendir/readdir
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
PaulG
n00b
n00b


Joined: 11 Jun 2003
Posts: 8

PostPosted: Sun Jan 11, 2004 2:24 pm    Post subject: Kernel memory leak in opendir/readdir Reply with quote

I have a problem on a machine that the kernel is gradually eating memory that is not freed from any user process or module and eventually causes the machine to crash.
I initially tracked it down to FAM (File Access Monitor), but it has turned out to be the calls that FAM is using, opendir, readdir and closedir.
Now (and here is the weird thing), it only happens on 1 of 5 pretty much identical (in terms of configuration) machines and only in certain directories. I am EXT3 based, and don't have any other filesystems types to try. I am including some code that demonstrates the problem.
WARNING: If you have the problem, then this progam will crash or cause you to have to reboot your machine. Do not run on critical machines or if you not prepared to have to reboot.
First the vital statistics:
Kernel: gentoo-sources-2.4.22-r3
Config:
Code:
CONFIG_EXT3_FS=y
# CONFIG_EXT3_FS_XATTR is not set
# CONFIG_EXT3_FS_XATTR_SHARING is not set
# CONFIG_EXT3_FS_XATTR_USER is not set
# CONFIG_EXT3_FS_XATTR_TRUSTED is not set
# CONFIG_EXT3_FS_POSIX_ACL is not set
CONFIG_JBD=y
# CONFIG_JBD_DEBUG is not set


Here is the code:
Code:

#define   _GNU_SOURCE
#include   <sys/types.h>
#include   <sys/stat.h>
#include   <fcntl.h>
#include   <dirent.h>
#include   <stdio.h>

// WARNING: May cause your machine to crash!

main()
{

   for (;;)
   {

      DIR *dir = opendir(".");
      if (dir == NULL)
      {
         perror("opendir");
         continue;
      }
      readdir(dir);
      closedir(dir);
   }
}

For me, the problem occurs if I run this in a directory called /home/paul/notify, but not in /home/paul.

Available memory falls quickly, and cannot be recovered even by stopping the program. Change the loop to run a specific number of times to see the loss without killing the machine.

If anyone can work out what the common factor in all this is, I would be grateful.

Thanks.
_________________
---
Paul
Back to top
View user's profile Send private message
kallamej
Administrator
Administrator


Joined: 27 Jun 2003
Posts: 4981
Location: Gothenburg, Sweden

PostPosted: Sun Jan 11, 2004 7:18 pm    Post subject: Reply with quote

Could be related to this bug report.
_________________
Please read our FAQ Forum, it answers many of your questions.
irc: #gentoo-forums on irc.libera.chat
Back to top
View user's profile Send private message
PaulG
n00b
n00b


Joined: 11 Jun 2003
Posts: 8

PostPosted: Sun Jan 11, 2004 8:48 pm    Post subject: Reply with quote

Well spotted!
Yes, the patch for this fixes the problem.
The test code has now been running for 5 minutes, and free memory has remained constant!

Thanks!
_________________
---
Paul
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum