From owner-freebsd-current@FreeBSD.ORG Wed Jan 28 12:02:51 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 40E4B106574C for ; Wed, 28 Jan 2009 12:02:51 +0000 (UTC) (envelope-from channa.kad@gmail.com) Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.225]) by mx1.freebsd.org (Postfix) with ESMTP id 00AC88FC32 for ; Wed, 28 Jan 2009 12:02:27 +0000 (UTC) (envelope-from channa.kad@gmail.com) Received: by rv-out-0506.google.com with SMTP id b25so7030222rvf.43 for ; Wed, 28 Jan 2009 04:02:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=gcZs0KOKqiRvN4sMiqBC0ghIyYaTCSYJdJppDJH3Ams=; b=WzozErHaGCq+hdvBhK9N4+ClPuv7Ho9dRMKm+KCdHNzGsYlcVVwYDttKct6jR3AG4T fT2oofiyQh4327usUif3kGoDOaUVtpEHCirJz6clV5WpnXiOI4yulUPdxg2Xsv3q421m 1ygxovtYq2/FxpUjrHBqGnfXgsADxOPYRI1go= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=J5Z2wZiDBqrDPNXDOZaMYvpRFQ/XTRsHMKajyv5rlumCJRGXjYIjIofT3VVal3iQEI C6NjxEUImvbraAYrJadeOZ6FXC+VPl04xmElGXrqBPPLWMVH4CUqujk0rIJC8XKg6kn5 FnvZUXGFfsVlNdbR+OmV9LGPdqoNuG8QXOorw= MIME-Version: 1.0 Received: by 10.141.197.21 with SMTP id z21mr1583237rvp.107.1233144147545; Wed, 28 Jan 2009 04:02:27 -0800 (PST) In-Reply-To: <20090128124535.M26828@beagle.kn.op.dlr.de> References: <515c64960901280339m17fa9309v2e1bc3f55454ab@mail.gmail.com> <20090128124535.M26828@beagle.kn.op.dlr.de> Date: Wed, 28 Jan 2009 17:32:27 +0530 Message-ID: <515c64960901280402s529d243fg8b6e0c58dc90b64@mail.gmail.com> From: Channa To: Harti Brandt Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-current@freebsd.org Subject: Re: Jemalloc SEGV for 1MB chunk X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Jan 2009 12:03:13 -0000 Hi, Thanks for your reply. You mean to say i should modify the test as below: #include #include #include int main() { int i; char *buf; size_t size = 1048576 ; buf = malloc(size); for (i = 0; i <= 1048575; i++) buf[i] = 'a'; buf[size]='\0'; printf("The length of buff is : %d\n",strlen(buf)); free(buf); return 0; } I NULL terminated the string buf[size] = '\0' <== The last character is NULL But still i get a SEGV at strlen. Could you please tell me if my changes above are correct? Regards, Channa On 28/01/2009, Harti Brandt wrote: > On Wed, 28 Jan 2009, Channa wrote: > > C>Hi All, > C>I am using jemalloc.c source from FreeBSD-current source. > C>When i allocate 1MB of memory using malloc() and use it as the below > C>test shows > C> > C>#include > C>#include > C>#include > C> > C>int main() > C>{ > C> int i; > C> char *buf; > C> size_t size = 1048576 ; > C> > C> buf = malloc(size); > C> for (i = 0; i < 1048576; i++) > C> buf[i] = 'a'; > C> printf("The length of buff is : %d\n",strlen(buf)); > C> free(buf); > C> return 0; > C>} > C> > C>When i try to call strlen(buf) SEGV is recived. > > Would be better to terminate the string with a '\0' so that it is really a > string. > > harti > > C> > C>This behaviour is seen when only for 1MB chunk if i allocate > C>memory lesser than 1MB no issues noticed. > C> > C>Could anyone see similar problem? > C>Is the above test wrong? > C>Or some issue with huge memory allocation in jemalloc? > C> > C>Your response will be very helpful. > C> > C>Thanks & Regards, > C>Channa > C>_______________________________________________ > C>freebsd-current@freebsd.org mailing list > C>http://lists.freebsd.org/mailman/listinfo/freebsd-current > C>To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" > C> > C> >