Blame SOURCES/valgrind-3.11.0-rlimit_data.patch

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