[ccache] build octave with ccache causes segfault when checkinstall

Joel Rosdahl joel at rosdahl.net
Wed Aug 3 12:17:22 MDT 2011

On 2011-07-04 14:44, Andreas Weber wrote:
> [...]
> andy at PhenomBabe:~/src/build_octave$ checkinstall
> ...
> /home/andy/src/build_octave/libtool: line 8970:  4125 Segmentation fault
>      ccache g++ -fPIC -DPIC -shared -nostdlib
> [...]
> This looks like ccache causes a segfault. I have reproduced this on
> different machines over the last 4 months.

I have now also reproduced the segfault. There's a bug in checkinstall's
installwatch wrapper that triggers a bug in ccache.

More specifically, checkinstall calls installwatch to run a command
whose file system accesses are to be watched, and this is done by
preloading installwatch.so, which wraps a number of functions. The
wrapped getcwd(buffer, size) function copies the result to the buffer
but returns a pointer to an internally allocated buffer (and leaks the
memory, by the way), which works for callers that do this:

	char buffer[MAXPATHLEN];
	if (!getcwd(buffer, sizeof(buffer)) {
		/* Failure */

But not for callers that do this:

	char buffer[MAXPATHLEN];
	if (getcwd(buffer, sizeof(buffer) != buffer) {
		/* Failure */

(getcwd is specified to return the buffer pointer on success, so both
versions are valid.) ccache does the latter, and then fails to handle
the failed getcwd call correctly.

I'll include a fix in ccache 3.1.6.

-- Joel

More information about the ccache mailing list