Created attachment 1686 [details]
Check for valgrind/memcheck.h on the system before using bundled copy.
Recently, in adding support for new architectures in Fedora, several issues were discovered with Valgrind, and addressed in 3.10.0. A bug was fixed with ppc32 and support was added for aarch64 and ppc64le. These changes require an updated valgrind.h and memcheck.h.
R is currently bundling a version of valgrind.h and memcheck.h that do not incorporate these fixes. Please update the bundled copies of these files to come from at least 3.10.0.
In addition, it would be useful for compilations of R with the --with-valgrind-instrumentation option set above 0 to first search for the system valgrind headers, and if found, use them in the compile instead of the bundled headers, to attempt to "future-proof" this scenario. I have attached a patch which does this.
Unfortunately it is not as simple as that: the names of the valgrind macros used in memory.c have been changed in valgrind 3.10.0, so allowing system headers would not 'future-proof' against further name changes.
We will investigate updating the included headers, but that needs considerable checking of the changes needed in memory.c.
It is unclear when the valgrind macros changed: it seems to be <= 3.8.0 but is not in their release notes.
The current status is that system headers can be used in R-devel via --with-system-valgrind-headers, but for valgrind >= 3.8.0, only instrumentation levels 1 and 2 are usable. It may take a long time to find out what they changed which breaks level 3.
It looks like the private copy of valgind.h/memcheck.h in the R source tree is more than 8 years old. Note the following from NEWS.old:
Release 3.2.0 (7 June 2006)
- There are some changes to Memcheck's client requests. Some of them
have changed names:
MAKE_NOACCESS --> MAKE_MEM_NOACCESS
MAKE_WRITABLE --> MAKE_MEM_UNDEFINED
MAKE_READABLE --> MAKE_MEM_DEFINED
CHECK_WRITABLE --> CHECK_MEM_IS_ADDRESSABLE
CHECK_READABLE --> CHECK_MEM_IS_DEFINED
CHECK_DEFINED --> CHECK_VALUE_IS_DEFINED
The reason for the change is that the old names are subtly
misleading. The old names will still work, but they are deprecated
and may be removed in a future release.
We also added a new client request:
which is like MAKE_MEM_DEFINED but only affects a byte if the byte is
- The way client requests are encoded in the instruction stream has
changed. Unfortunately, this means 3.2.0 will not honour client
requests compiled into binaries using headers from earlier versions
of Valgrind. We will try to keep the client request encodings more
stable in future.
Release 3.3.0 (7 December 2007)
- The following Memcheck client requests have been removed:
They were deprecated in 3.2.0, when equivalent but better-named client
requests were added. See the 3.2.0 release notes for more details.
As far as I know there were no user visible changes to the macros since then (except for adding support for new client requests, new architectures and bug fixes like the ppc32 one).
Headers updated to those from valgrind 3.10.1;
support for instrumentation level 3 withdrawn.