Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Other Things Gentoo
  • Search

Kernel memory leak in opendir/readdir

Still need help with Gentoo, and your question doesn't fit in the above forums? Here is your last bastion of hope.
Post Reply
Advanced search
3 posts • Page 1 of 1
Author
Message
PaulG
n00b
n00b
Posts: 8
Joined: Wed Jun 11, 2003 8:19 pm

Kernel memory leak in opendir/readdir

  • Quote

Post by PaulG » Sun Jan 11, 2004 2:24 pm

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: Select all

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: Select all

#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
Top
kallamej
Administrator
Administrator
User avatar
Posts: 4994
Joined: Fri Jun 27, 2003 10:05 am
Location: Gothenburg, Sweden

  • Quote

Post by kallamej » Sun Jan 11, 2004 7:18 pm

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
Top
PaulG
n00b
n00b
Posts: 8
Joined: Wed Jun 11, 2003 8:19 pm

  • Quote

Post by PaulG » Sun Jan 11, 2004 8:48 pm

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
Top
Post Reply

3 posts • Page 1 of 1

Return to “Other Things Gentoo”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Authors
Gentoo is a trademark of the Gentoo Foundation, Inc. and of Förderverein Gentoo e.V.
The contents of this document, unless otherwise expressly stated, are licensed under the CC-BY-SA-4.0 license.
The Gentoo Name and Logo Usage Guidelines apply.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy