From owner-freebsd-hackers@FreeBSD.ORG Thu Sep 8 12:59:02 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 256D316A41F for ; Thu, 8 Sep 2005 12:59:02 +0000 (GMT) (envelope-from cole@opteqint.net) Received: from elektra.opteqint.net (elektra.opteqint.net [209.25.178.105]) by mx1.FreeBSD.org (Postfix) with ESMTP id BDFB943D46 for ; Thu, 8 Sep 2005 12:59:01 +0000 (GMT) (envelope-from cole@opteqint.net) Received: from [196.47.3.46] (helo=deadmind) by elektra.opteqint.net with esmtpsa (TLSv1:RC4-MD5:128) (Exim 4.52 (FreeBSD)) id 1EDLzX-000GgD-Eg for freebsd-hackers@freebsd.org; Thu, 08 Sep 2005 05:59:03 -0700 From: "Cole" To: Date: Thu, 8 Sep 2005 15:01:53 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 Thread-Index: AcW0dXvMsIOPgagFQ369vrbHgOhM4Q== X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4939.300 X-Spam-Score: -99.4 (---------------------------------------------------) X-Spam-Report: Spam detection software, running on the system "elektra.opteqint.net", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi I have the netapp code they release for icap server. Ive ported it to FreeBSD. And I have found there is a memory leak in the code itself. Ive tried contacting netapp directly, but no reply. Their code can be found at : http://www.i-cap.org/spec/icap-server10.tar.gz [...] Content analysis details: (-99.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -100 USER_IN_WHITELIST From: address is in the user's white-list 0.6 J_CHICKENPOX_43 BODY: 4alpha-pock-3alpha Message-Id: <20050908125901.BDFB943D46@mx1.FreeBSD.org> Subject: Memory Leak && Free Problem X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: cole@opteqint.net List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Sep 2005 12:59:02 -0000 Hi I have the netapp code they release for icap server. Ive ported it to FreeBSD. And I have found there is a memory leak in the code itself. Ive tried contacting netapp directly, but no reply. Their code can be found at : http://www.i-cap.org/spec/icap-server10.tar.gz Ive been trying to fix the memory leak, and I think i've found the problem, but when I try to free the buffer, I get this error. icap_srv in free(): warning: page is already free In the function : api_modify_respmod(const char* icap_hdr, const char* client_hdr, const char* origin_resp_hdr, const char* origin_resp_body, int origin_resp_body_len) We have this section of code: 1. new_body = api_filter(origin_resp_body,origin_resp_body_len); 2. origin_resp_body_len = new_body->length; 3. origin_resp_body = new_body->data; I figure that the memory leak is occuring with origin_resp_body being assigned to the new_body buffer. But if I try to insert a free(origin_resp_body) between line 1. and 2. I get the error "icap_srv in free(): warning: page is already free" when running the program, or either the error "free(): warning: junk pointer, too high to make sense" I was wondering if there is somethign missing here. Ive checked the function api_filter, and it doesnt do anything in regards to free'ing origin_resp_body, and ive also checked the data in the buffer origin_resp_body before and after the function call to api_filter, and both values are exactly the same. The entire program is threaded, and I suppose it could be possible there is some kind of thread problem occuring here? Ive also run the program through valgrind, to try and find the other memory leaks, but that one seems the most obvious when going through the code. Anyway, I would just like to know if anyone has any ideas or suggestions, or to point out that im a complete moron and missing something, anything would be welcome. Regards /Cole