The error comes from here:
// coregrind/m_libcfile.c
/* Create and open (-rw------) a tmp file name incorporating said arg.
Returns -1 on failure, else the fd of the file. If fullname is
non-NULL, the file's name is written into it. The number of bytes
written is guaranteed not to exceed 64+strlen(part_of_name). */
Int VG_(mkstemp) ( HChar* part_of_name, /*OUT*/HChar* fullname )
{
HChar buf[200];
Int n, tries, fd;
UInt seed;
SysRes sres;
const HChar *tmpdir;
vg_assert(part_of_name);
n = VG_(strlen)(part_of_name);
vg_assert(n > 0 && n < 100);
seed = (VG_(getpid)() << 9) ^ VG_(getppid)();
/* Determine sensible location for temporary files */
tmpdir = VG_(tmpdir)();
tries = 0;
while (True) {
if (tries++ > 10)
return -1;
VG_(sprintf)( buf, "%s/valgrind_%s_%08x",
tmpdir, part_of_name, VG_(random)( &seed ));
if (0)
VG_(printf)("VG_(mkstemp): trying: %s\n", buf);
sres = VG_(open)(buf,
VKI_O_CREAT|VKI_O_RDWR|VKI_O_EXCL|VKI_O_TRUNC,
VKI_S_IRUSR|VKI_S_IWUSR);
if (sr_isError(sres)) {
VG_(umsg)("VG_(mkstemp): failed to create temp file: %s\n", buf);
continue;
}
/* VG_(safe_fd) doesn't return if it fails. */
fd = VG_(safe_fd)( sr_Res(sres) );
if (fullname)
VG_(strcpy)( fullname, buf );
return fd;
}
/* NOTREACHED */
}
As you can see, that code will fail if there are more than 10 processes that share the same pid
and ppid
. It is not clear how you are creating the 20 valgrind processes -- they should normally not share pid
.
You might be able to work around the problem by either
- creating your Valgrind instances such that they do not share the same
pid
, or - setting
TMPDIR
to a different directory for each of the Valgrind instance.