From owner-freebsd-questions@FreeBSD.ORG Fri May 21 15:58:50 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1D4CD1065674 for ; Fri, 21 May 2010 15:58:50 +0000 (UTC) (envelope-from Vikash.Badal@is.co.za) Received: from morpheus.is.co.za (morpheus.is.co.za [196.35.45.229]) by mx1.freebsd.org (Postfix) with ESMTP id 969F28FC08 for ; Fri, 21 May 2010 15:58:49 +0000 (UTC) Received: from morpheus.is.co.za (localhost.is.co.za [127.0.0.1]) by morpheus.is.co.za (Postfix) with ESMTP id 75D50F340F for ; Fri, 21 May 2010 17:58:47 +0200 (SAST) Received: from rs-aplha.mfw.is.co.za (rs-alpha.mfw.is.co.za [196.26.2.112]) by morpheus.is.co.za (Postfix) with ESMTP id 3CA10F32B5 for ; Fri, 21 May 2010 17:58:47 +0200 (SAST) Received: from root by rs-aplha.mfw.is.co.za with local (Exim 4.69) (envelope-from ) id 1OFUZh-000J8o-03 for freebsd-questions@freebsd.org; Fri, 21 May 2010 17:55:49 +0200 Received: from exim by rs-aplha.mfw.is.co.za with split (Exim 4.69) (envelope-from ) id 1OFUZa-000J7y-1y for freebsd-questions@freebsd.org; Fri, 21 May 2010 17:55:42 +0200 Received: from [196.26.2.106] (helo=ZABRYSVISMFW) by rs-aplha.mfw.is.co.za with esmtp (Exim 4.69) (envelope-from ) id 1OFUZZ-000J7v-SP for freebsd-questions@freebsd.org; Fri, 21 May 2010 17:55:41 +0200 Received: from zabrysvisexhub3.af.didata.local (Not Verified[10.1.8.38]) by ZABRYSVISMFW with MailMarshal (v6,5,4,7535) id ; Fri, 21 May 2010 17:58:48 +0200 Received: from ZABRYSVISEXMBX1.af.didata.local ([fe80::914a:a14c:13c1:d279]) by zabrysvisexhub3.af.didata.local ([fe80::9023:67c3:e2b7:a5ba%10]) with mapi; Fri, 21 May 2010 17:58:04 +0200 From: Vikash Badal To: "freebsd-questions@freebsd.org" Date: Fri, 21 May 2010 17:58:31 +0200 Thread-Topic: threads and malloc/free on freebsd 8.0 Thread-Index: Acr4/nWBtJH08K8LQF2QG0p7qeSiSQ== Message-ID: <9B425C841283E0418B1825D40CBCFA613D9E2689CF@ZABRYSVISEXMBX1.af.didata.local> Accept-Language: en-US, en-ZA Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-cr-hashedpuzzle: vSQ= AUpH BJiP BmhQ EPR1 F9La HtLQ IO6t In9r JZhI JrS6 KN4Q K4nd MCrs MKab MOEx; 1; ZgByAGUAZQBiAHMAZAAtAHEAdQBlAHMAdABpAG8AbgBzAEAAZgByAGUAZQBiAHMAZAAuAG8AcgBnAA==; Sosha1_v1; 7; {E7F73DE1-16D8-40EC-862E-D1E84100DA9B}; dgBpAGsAYQBzAGgALgBiAGEAZABhAGwAQABpAHMALgBjAG8ALgB6AGEA; Fri, 21 May 2010 15:58:31 GMT; dABoAHIAZQBhAGQAcwAgAGEAbgBkACAAbQBhAGwAbABvAGMALwBmAHIAZQBlACAAIABvAG4AIABmAHIAZQBlAGIAcwBkACAAOAAuADAA x-cr-puzzleid: {E7F73DE1-16D8-40EC-862E-D1E84100DA9B} acceptlanguage: en-US, en-ZA Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Recipient-Count: 1 X-Mailer: Microsoft Office Outlook, Build 11.0.5510 X-Virus-Scanned: ClamAV using ClamSMTP Subject: threads and malloc/free on freebsd 8.0 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 May 2010 15:58:50 -0000 Greetings. Excuse me if this is a stupid questions. I have a thread socket application that seems to be behaving strangely In a worker thread, I have the following. ----------- =20 LogMessage(DEBUG_0, "allocated %ld", malloc_usable_size(inst)); =20 =20 =20 free(inst); =20 =20 =20 LogMessage(DEBUG_0, "after free allocated %ld", malloc_usable_size(i= nst)); =20 =20 =20 return 0; ----------- output> allocated 2304 output> after free allocated 2304 from playing around, this should have segfaulted but it didn't: if I try this from a non threaded, non socket code: ------------------ =20 char *z; =20 z =3D (char*)malloc(1000); =20 printf("malloc is %ld\n", malloc_usable_size(z)); =20 free(z); =20 printf("after malloc is %ld\n", malloc_usable_size(z)); ------------------ Output> malloc is 1024 Output> Segmentation fault (core dumped) Can anyone enlighten me ? If im not clear, please forgive me. Please note: This email and its content are subject to the disclaimer as = displayed at the following link http://www.is.co.za/legal/E-mail+Confiden= tiality+Notice+and+Disclaimer.htm. Should you not have Web access, send a= =20mail to disclaimers@is.co.za and a copy will be emailed to you.