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