Add valgrind-3.11.0-rlimit_data.patch

This commit is contained in:
Mark Wielaard 2016-01-20 19:27:58 +01:00
parent ebed60be0b
commit 8963780801
2 changed files with 123 additions and 0 deletions

View File

@ -0,0 +1,116 @@
diff --git a/coregrind/m_libcproc.c b/coregrind/m_libcproc.c
index f314b55..a30f7dc 100644
--- a/coregrind/m_libcproc.c
+++ b/coregrind/m_libcproc.c
@@ -450,9 +450,6 @@ void VG_(execv) ( const HChar* filename, const HChar** argv )
HChar** envp;
SysRes res;
- /* restore the DATA rlimit for the child */
- VG_(setrlimit)(VKI_RLIMIT_DATA, &VG_(client_rlimit_data));
-
envp = VG_(env_clone)(VG_(client_envp));
VG_(env_remove_valgrind_env_stuff)( envp, True /*ro_strings*/, NULL );
@@ -511,17 +508,9 @@ Int VG_(spawn) ( const HChar *filename, const HChar **argv )
# undef COPY_CHAR_TO_ARGENV
# undef COPY_STRING_TOARGENV
- /* HACK: Temporarily restore the DATA rlimit for spawned child. */
- VG_(setrlimit)(VKI_RLIMIT_DATA, &VG_(client_rlimit_data));
-
SysRes res = VG_(do_syscall5)(__NR_spawn, (UWord) filename, (UWord) NULL, 0,
(UWord) argenv, argenv_size);
- /* Restore DATA rlimit back to its previous value set in m_main.c. */
- struct vki_rlimit zero = { 0, 0 };
- zero.rlim_max = VG_(client_rlimit_data).rlim_max;
- VG_(setrlimit)(VKI_RLIMIT_DATA, &zero);
-
VG_(free)(argenv);
for (HChar **p = envp; *p != NULL; p++) {
VG_(free)(*p);
diff --git a/coregrind/m_main.c b/coregrind/m_main.c
index 1821c94..9b659ae 100644
--- a/coregrind/m_main.c
+++ b/coregrind/m_main.c
@@ -1627,7 +1627,6 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp )
Bool logging_to_fd = False;
const HChar* xml_fname_unexpanded = NULL;
Int loglevel, i;
- struct vki_rlimit zero = { 0, 0 };
XArray* addr2dihandle = NULL;
//============================================================
@@ -1800,13 +1799,15 @@ Int valgrind_main ( Int argc, HChar **argv, HChar **envp )
VG_(debugLog)(1, "main", "... %s\n", VG_(name_of_launcher));
//--------------------------------------------------------------
- // Get the current process datasize rlimit, and set it to zero.
- // This prevents any internal uses of brk() from having any effect.
- // We remember the old value so we can restore it on exec, so that
- // child processes will have a reasonable brk value.
+ // We used to set the process datasize rlimit to zero to prevent
+ // any internal use of brk() from having any effect. But later
+ // linux kernels redefine RLIMIT_DATA as the size of any data
+ // areas, including some dynamic mmap memory allocations.
+ // See bug #357833 for the commit that went into linux 4.5
+ // changing the definition of RLIMIT_DATA. So don't mess with
+ // RLIMIT_DATA here now anymore. Just remember it for use in
+ // the syscall wrappers.
VG_(getrlimit)(VKI_RLIMIT_DATA, &VG_(client_rlimit_data));
- zero.rlim_max = VG_(client_rlimit_data).rlim_max;
- VG_(setrlimit)(VKI_RLIMIT_DATA, &zero);
// Get the current process stack rlimit.
VG_(getrlimit)(VKI_RLIMIT_STACK, &VG_(client_rlimit_stack));
diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c
index aa60d67..061c1e1 100644
--- a/coregrind/m_syswrap/syswrap-generic.c
+++ b/coregrind/m_syswrap/syswrap-generic.c
@@ -3014,9 +3014,6 @@ PRE(sys_execve)
vg_assert(j == tot_args+1);
}
- /* restore the DATA rlimit for the child */
- VG_(setrlimit)(VKI_RLIMIT_DATA, &VG_(client_rlimit_data));
-
/*
Set the signal state up for exec.
diff --git a/coregrind/m_syswrap/syswrap-solaris.c b/coregrind/m_syswrap/syswrap-solaris.c
index 4e2662c..c700b59 100644
--- a/coregrind/m_syswrap/syswrap-solaris.c
+++ b/coregrind/m_syswrap/syswrap-solaris.c
@@ -1589,21 +1589,12 @@ PRE(sys_spawn)
#undef COPY_CHAR_TO_ARGENV
#undef COPY_STRING_TOARGENV
- /* HACK: Temporarily restore the DATA rlimit for spawned child.
- This is a terrible hack to provide sensible brk limit for child. */
- VG_(setrlimit)(VKI_RLIMIT_DATA, &VG_(client_rlimit_data));
-
/* Actual spawn() syscall. */
SysRes res = VG_(do_syscall5)(__NR_spawn, (UWord) path, (UWord) attrs,
attrs_size, (UWord) argenv, argenv_size);
SET_STATUS_from_SysRes(res);
VG_(free)(argenv);
- /* Restore DATA rlimit back to its previous value set in m_main.c. */
- struct vki_rlimit zero = { 0, 0 };
- zero.rlim_max = VG_(client_rlimit_data).rlim_max;
- VG_(setrlimit)(VKI_RLIMIT_DATA, &zero);
-
if (SUCCESS) {
PRINT(" spawn: process %d spawned child %ld\n", VG_(getpid)(), RES);
}
@@ -3794,9 +3785,6 @@ PRE(sys_execve)
VG_(sigprocmask)(VKI_SIG_SETMASK, &tst->sig_mask, NULL);
}
- /* Restore the DATA rlimit for the child. */
- VG_(setrlimit)(VKI_RLIMIT_DATA, &VG_(client_rlimit_data));
-
/* Debug-only printing. */
if (0) {
HChar **cpp;

View File

@ -79,6 +79,9 @@ Patch10: valgrind-3.11.0-aspacemgr.patch
# KDE#358213 - helgrind bar_bad testcase hangs with new glibc pthread barrier # KDE#358213 - helgrind bar_bad testcase hangs with new glibc pthread barrier
Patch11: valgrind-3.11.0-pthread_barrier.patch Patch11: valgrind-3.11.0-pthread_barrier.patch
# KDE#357833 - Valgrind is broken on recent linux kernel (RLIMIT_DATA)
Patch12: valgrind-3.11.0-rlimit_data.patch
%if %{build_multilib} %if %{build_multilib}
# Ensure glibc{,-devel} is installed for both multilib arches # Ensure glibc{,-devel} is installed for both multilib arches
BuildRequires: /lib/libc.so.6 /usr/lib/libc.so /lib64/libc.so.6 /usr/lib64/libc.so BuildRequires: /lib/libc.so.6 /usr/lib/libc.so /lib64/libc.so.6 /usr/lib64/libc.so
@ -194,6 +197,7 @@ Valgrind User Manual for details.
%patch9 -p1 %patch9 -p1
%patch10 -p1 %patch10 -p1
%patch11 -p1 %patch11 -p1
%patch12 -p1
%build %build
# We need to use the software collection compiler and binutils if available. # We need to use the software collection compiler and binutils if available.
@ -369,6 +373,9 @@ echo ===============END TESTING===============
%endif %endif
%changelog %changelog
* Wed Jan 20 2016 Mark Wielaard <mjw@redhat.com>
- Add valgrind-3.11.0-rlimit_data.patch
* Tue Jan 19 2016 Mark Wielaard <mjw@redhat.com> - 3.11.0-7 * Tue Jan 19 2016 Mark Wielaard <mjw@redhat.com> - 3.11.0-7
- Add valgrind-3.11.0-pthread_barrier.patch - Add valgrind-3.11.0-pthread_barrier.patch