ccache on amd64
fbsd.questions at rachie.is-a-geek.net
Thu Sep 25 13:49:43 UTC 2008
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
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.
--- 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)
args->argv = (char**)x_realloc(args->argv, (args->argc + 2) *
+ args->argv = reallocf((char *)args->argv, (args->argc + 2) *
+ if( args->argv == NULL )
+ fatal("out of memory in reallocf");
args->argv[args->argc] = x_strdup(s);
args->argv[args->argc] = NULL;
More information about the freebsd-questions