From owner-freebsd-current@FreeBSD.ORG Mon Feb 2 14:23:39 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 98859106564A for ; Mon, 2 Feb 2009 14:23:39 +0000 (UTC) (envelope-from ianf@clue.co.za) Received: from inbound01.jnb1.gp-online.net (inbound01.jnb1.gp-online.net [41.161.16.135]) by mx1.freebsd.org (Postfix) with ESMTP id 286DB8FC0C for ; Mon, 2 Feb 2009 14:23:38 +0000 (UTC) (envelope-from ianf@clue.co.za) Received: from [196.7.162.28] (helo=clue.co.za) by inbound01.jnb1.gp-online.net with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1LTzAC-0006gd-Ds; Mon, 02 Feb 2009 15:48:36 +0200 Received: from localhost ([127.0.0.1] helo=clue.co.za) by clue.co.za with esmtp (Exim 4.69 (FreeBSD)) (envelope-from ) id 1LTzA5-0005zc-OH; Mon, 02 Feb 2009 15:48:29 +0200 To: Channa From: Ian FREISLICH In-Reply-To: <515c64960901280425y642a190ka31409cfc2a2fd8f@mail.gmail.com> References: <515c64960901280425y642a190ka31409cfc2a2fd8f@mail.gmail.com> <515c64960901280339m17fa9309v2e1bc3f55454ab@mail.gmail.com> <49804597.6040303@gmx.de> <515c64960901280401w1e1d08bfx29adc124bc749c4a@mail.gmail.com> X-Attribution: BOFH Date: Mon, 02 Feb 2009 15:48:29 +0200 Message-Id: Cc: Christoph Mallon , 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: Mon, 02 Feb 2009 14:23:39 -0000 Channa wrote: > Thanks for the reply. > > I understand , after terminating the string with NULL character no > SEGV is seen. > > But if i change the request size to a value less than 1MB for eg: 4096 > Bytes, > > I dont see any issues, without terminating the string with NULL > character the test code works fine. The issue is seen only for size > 1MB exactly. > > Can anyone explain this behaviour? It's probably caused because although you asked for 4096 bytes of memory a larger chunk was allocated so that a subsequent malloc calls need not make a system call but can allocate from unallocated allocated memory. It's also likely that the memory was zeroed by malloc so the string was NULL terminated "by accident". Ian -- Ian Freislich