[Rd] valgrind and C++
Jarrod Hadfield
j.hadfield at ed.ac.uk
Mon Mar 17 18:26:12 CET 2014
Hi,
I am sorry if this is perceived as a C++ question rather than an R
question. After uploading an R library to CRAN (MCMCglmm) the C++ code
failed to pass the memory checks. The errors come in pairs like:
Mismatched free() / delete / delete []
at 0x4A077E6: free (vg_replace_malloc.c:446)
by 0x144FA28E: MCMCglmm (MCMCglmm.cc:2184)
Address 0x129850c0 is 0 bytes inside a block of size 4 alloc'd
at 0x4A07CE4: operator new[](unsigned long) (vg_replace_malloc.c:363)
by 0x144F12B7: MCMCglmm (MCMCglmm.cc:99)
which is associated with lines allocating and freeing memory (nG is an
integer):
int *keep = new int [nG];
and
delete [] keep;
To me this looks fine, and on my machine (Scientific Linux 6.4) using
gcc 4.4.7-3 and valgrind 1:3.8.1-3.2 I get no such errors. Its not
clear to me which flavour of Linux or compiler the CRAN team used,
although from MCMCglmm-Ex.Rout I can see the same version of valgrind
was used. Any insight would be very welcome.
Kind Regards,
Jarrod
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
More information about the R-devel
mailing list