LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-20-2004, 02:11 PM   #1
Xagafinelle
LQ Newbie
 
Registered: Aug 2004
Distribution: SlackWare
Posts: 11

Rep: Reputation: 0
valgrind reports un-free'd memory in crypt()?


Hello all,

I was just wondering if anyone knew about this issue. From what I understand, crypt() uses a statically allocated buffer to store it's output when doing encryption, and returns a pointer to that buffer, much like the readdir function. Now, the issue really is just that valgrind complains when I run a full memcheck with it after my program uses crypt. However, if I try to free the memory and crypt is called a seccond time I get a much worse error, that previously unallocated memory is being written to.

This isn't really a problem as far as I can see, my program runs fine, and linux is clever enough to clean up the 65 bytes that crypt never frees, but I would like to know if I'm missing a crypt-free() routine or something, or if this is simply a bug in valgrind.

Anyone have any ideas?
Thanks,
--Xagafinelle

(P.S. I couldn't find much documentation on crypt-lib, there may be something I'm missing, although the functions work great!)

(P.P.S. I am using C++ on a linux system, and as far as I know I have the latest version of libcrypt. Yeah, you heard me, C++ Strike... )
 
Old 08-20-2004, 05:08 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
It looks that crypt's using the same buffer for all results it returns. It doesn't look like a valgrind bug - such things just happen. I don't know nothing about crypt-free or something like thath Haven't looked into crypt sources, through.
 
Old 08-20-2004, 05:37 PM   #3
Xagafinelle
LQ Newbie
 
Registered: Aug 2004
Distribution: SlackWare
Posts: 11

Original Poster
Rep: Reputation: 0
Well, right, it maintains a single buffer, more or less, it does use a realloc on it if you call it again. But it definately is not static, is my point, and valgrind knows this.

What I was asking was that if this is really not an issue because the memory is being free'd and valgrind is checking it too early, or something of that nature, I know there were plenty of issues like that in previous versions, or if this is an issue in crypt itself, since there is no easy way for me to free this memory.

Really, I just want valgrind to return a clean report, there's a certain amount of pride there, 'sides, it looks nicer.

I checked the headers for libcrypt, and they have nothing in them but the crypt functions, and nothing else.

Anybody?
--Xagafinelle
 
Old 08-21-2004, 11:02 AM   #4
cracauer
Member
 
Registered: Jul 2004
Location: Boston, MA, USA
Distribution: FreeBSD, Debian/AMD64, Ubuntu/i386
Posts: 59

Rep: Reputation: 15
There are a number of librarues which find it OK to have one constant memory "leak", that means some permanent data structure is allocated once at library startup and never cleaned up.[*]

Re-run the test to see whether 1000 uses of the library cause more memory to leak.
[*]Don't blame them too hard, they just want to avoid requiring the user to call some shutdown function and many people don't like to register random atexit() handlers.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Valgrind - an answer. cyent Programming 6 02-11-2010 01:49 PM
Valgrind and Shared Memory nodger Programming 0 04-27-2005 07:29 AM
Valgrind 2.2.0 works sridurai Linux - General 0 02-18-2005 05:51 AM
top reports 99% memory used when using a tmpfs damonnew Linux - General 1 01-30-2005 01:51 AM
Top reports > 100% Memory use by X sparky6969 Linux - General 2 07-20-2001 09:05 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration