From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/4422 Path: news.gmane.org!not-for-mail From: David Wuertele Newsgroups: gmane.linux.lib.musl.general Subject: Re: NULL deref SEGV in malloc.c:unbin() Date: Sat, 28 Dec 2013 00:25:20 +0000 (UTC) Message-ID: References: <20131227190544.GF24286@brightrain.aerifal.cx> <20131227221345.GG24286@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1388190348 29766 80.91.229.3 (28 Dec 2013 00:25:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 28 Dec 2013 00:25:48 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-4426-gllmg-musl=m.gmane.org@lists.openwall.com Sat Dec 28 01:25:55 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1Vwhj0-0002cF-TZ for gllmg-musl@plane.gmane.org; Sat, 28 Dec 2013 01:25:54 +0100 Original-Received: (qmail 1477 invoked by uid 550); 28 Dec 2013 00:25:54 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 1469 invoked from network); 28 Dec 2013 00:25:54 -0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 40 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: sea.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 205.234.27.227 (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36) Xref: news.gmane.org gmane.linux.lib.musl.general:4422 Archived-At: Rich Felker aerifal.cx> writes: > > On Fri, Dec 27, 2013 at 07:44:23PM +0000, David Wuertele wrote: > > Rich Felker aerifal.cx> writes: > > > On Fri, Dec 27, 2013 at 06:35:00PM +0000, David Wuertele wrote: > > > > I wonder if anyone has hit this before? In unbin(), > > > > c->next->prev is set, but c->next is NULL. It happens > > > > repeatedly, and here's what gdb says: > > > > > > > > > > It's almost surely a case of memory corruption by the calling > > > program, most likely using memory after it's already been > > > freed. > > > > Hmm, my program calls malloc() once and never calls free(). > > And this crash happens on the very first call to malloc? Or did you > mean it only called it once successfully? > I only call malloc directly once, and it succeeds. I use the allocation only for a circular buffer. I have an extremely high confidence that the circular buffer does not write outside of its memory allocation. I see that malloc is called many times when I run opendir()/closedir() and other musl library functions. It is during one of the closedir() that I see the SEGV. The SEGV happens when mal.bins[40].head.next is dereferenced but mal.bins[40].head.next is NULL. So I am running my program under gdb while watching mal.bins[40].head. I see that nobody except for the musl lib writes to mal.bins[40], but I have not seen any of those writes result in a NULL value in *->next. Now I am watching all memory locations that mal.bins[40].head points to in its history, but the going is very slow. Dave