From owner-freebsd-questions@FreeBSD.ORG Thu Sep 25 13:49:43 2008 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 BB55C1065688; Thu, 25 Sep 2008 13:49:43 +0000 (UTC) (envelope-from fbsd.questions@rachie.is-a-geek.net) Received: from mail.rachie.is-a-geek.net (rachie.is-a-geek.net [66.230.99.27]) by mx1.freebsd.org (Postfix) with ESMTP id 469D98FC21; Thu, 25 Sep 2008 13:49:43 +0000 (UTC) (envelope-from fbsd.questions@rachie.is-a-geek.net) Received: from localhost (mail.rachie.is-a-geek.net [192.168.2.101]) by mail.rachie.is-a-geek.net (Postfix) with ESMTP id 5F84CAFBC01; Thu, 25 Sep 2008 05:49:42 -0800 (AKDT) From: Mel To: freebsd-questions@freebsd.org Date: Thu, 25 Sep 2008 15:49:41 +0200 User-Agent: KMail/1.9.7 References: <48D7092B.1040503@brianwhalen.net> <200809251250.25782.fbsd.questions@rachie.is-a-geek.net> In-Reply-To: <200809251250.25782.fbsd.questions@rachie.is-a-geek.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200809251549.41342.fbsd.questions@rachie.is-a-geek.net> Cc: Brian , ahze@freebsd.org Subject: Re: ccache on amd64 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: Thu, 25 Sep 2008 13:49:43 -0000 On Thursday 25 September 2008 12:50:25 Mel wrote: > On Monday 22 September 2008 04:55:39 Brian wrote: > > Has there been any change in the above? On a single core i386, the > > documentation described notes work properly. However, on a AM2 based > > machine with the amd64 version of freebsd (both 6.4 Beta and 7.0 show > > this behavior) I consistently get the below error. > > Ok - I can reproduce this, but not even the LIB32_COMPAT libs, but already > earlier. The core dump shows an error in memcpy(). I'll rebuild ccache with > debug symbols and see if I can figure this out. Ok, cracked it. ccache will dump core, if the argument list >255 arguments, most likely because the page size is 2048 bytes, but I'm guessing here. What happens in x_realloc is that it wants to copy the 2048+8 from the old pointer to the new, yet the old pointer is only 2040 bytes big. I think it goes ok, till 2048, because 2048 is allocated regardless. You won't see this on 32-bits, because you don't hit this size as the pointer size is only 4 bytes. Most likely, you will hit this bug with argument list >510 arguments. The patch inlined below my sig will fix the problem. I'll file a PR so that ahze@ can fix it properly. Save it as /usr/ports/devel/ccache/files/patch-args.c and reinstall ccache. -- Mel --- args.c.orig 2004-09-13 02:38:30.000000000 -0800 +++ args.c 2008-09-25 04:58:35.000000000 -0800 @@ -37,7 +37,13 @@ void args_add(ARGS *args, const char *s) { +#ifndef __FreeBSD__ args->argv = (char**)x_realloc(args->argv, (args->argc + 2) * sizeof(char *)); +#else + args->argv = reallocf((char *)args->argv, (args->argc + 2) * sizeof(char *)); + if( args->argv == NULL ) + fatal("out of memory in reallocf"); +#endif args->argv[args->argc] = x_strdup(s); args->argc++; args->argv[args->argc] = NULL;