Date: Thu, 25 Sep 2008 15:49:41 +0200 From: Mel <fbsd.questions@rachie.is-a-geek.net> To: freebsd-questions@freebsd.org Cc: Brian <bri@brianwhalen.net>, ahze@freebsd.org Subject: Re: ccache on amd64 Message-ID: <200809251549.41342.fbsd.questions@rachie.is-a-geek.net> In-Reply-To: <200809251250.25782.fbsd.questions@rachie.is-a-geek.net> References: <48D7092B.1040503@brianwhalen.net> <200809251250.25782.fbsd.questions@rachie.is-a-geek.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200809251549.41342.fbsd.questions>