[ 
https://issues.apache.org/jira/browse/MESOS-5021?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Benjamin Mahler updated MESOS-5021:
-----------------------------------
    Fix Version/s: 0.24.2
                   0.25.1
                   0.26.1
                   0.23.2
                   0.27.3

> Memory leak in subprocess when 'environment' argument is provided.
> ------------------------------------------------------------------
>
>                 Key: MESOS-5021
>                 URL: https://issues.apache.org/jira/browse/MESOS-5021
>             Project: Mesos
>          Issue Type: Bug
>          Components: libprocess, slave
>    Affects Versions: 0.23.0, 0.23.1, 0.24.0, 0.24.1, 0.25.0, 0.26.0, 0.27.0, 
> 0.27.1, 0.28.0, 0.27.2
>            Reporter: Benjamin Mahler
>            Assignee: Benjamin Mahler
>            Priority: Blocker
>             Fix For: 0.26.1, 0.25.1, 0.24.2, 0.28.1, 0.27.3, 0.23.2
>
>
> A memory leak in process::subprocess was introduced here:
> https://github.com/apache/mesos/commit/14b49f31840ff1523b31007c21b12c604700323f
> This was found when [~jieyu] and I examined a memory leak in the health check 
> program (see MESOS-4869).
> The leak is here:
> https://github.com/apache/mesos/blob/0.28.0/3rdparty/libprocess/src/subprocess.cpp#L451-L456
> {code}
>   // Like above, we need to construct the environment that we'll pass
>   // to 'os::execvpe' as it might not be async-safe to perform the
>   // memory allocations.
>   char** envp = os::raw::environment();
>   if (environment.isSome()) {
>     // NOTE: We add 1 to the size for a NULL terminator.
>     envp = new char*[environment.get().size() + 1];
>     size_t index = 0;
>     foreachpair (const string& key, const string& value, environment.get()) {
>       string entry = key + "=" + value;
>       envp[index] = new char[entry.size() + 1];
>       strncpy(envp[index], entry.c_str(), entry.size() + 1);
>       ++index;
>     }
>     envp[index] = NULL;
>   }
>   ...
>   // Need to delete 'envp' if we had environment variables passed to
>   // us and we needed to allocate the space.
>   if (environment.isSome()) {
>     CHECK_NE(os::raw::environment(), envp);
>     delete[] envp; // XXX Does not delete the sub arrays.
>   }
> {code}
> Auditing the code, it appears to affect a number of locations:
> * 
> [docker::run|https://github.com/apache/mesos/blob/0.28.0/src/docker/docker.cpp#L661-L668]
> * [health check 
> binary|https://github.com/apache/mesos/blob/0.28.0/src/health-check/main.cpp#L177-L205]
> * 
> [liblogrotate|https://github.com/apache/mesos/blob/0.28.0/src/slave/container_loggers/lib_logrotate.cpp#L137-L194]
> * Docker containerizer: 
> [here|https://github.com/apache/mesos/blob/0.28.0/src/slave/containerizer/docker.cpp#L1207-L1220]
>  and 
> [here|https://github.com/apache/mesos/blob/0.28.0/src/slave/containerizer/docker.cpp#L1119-L1131]
> * [External 
> containerizer|https://github.com/apache/mesos/blob/0.28.0/src/slave/containerizer/external_containerizer.cpp#L479-L483]
> * [Posix 
> launcher|https://github.com/apache/mesos/blob/0.28.0/src/slave/containerizer/mesos/launcher.cpp#L131-L141]
>  and [Linux 
> launcher|https://github.com/apache/mesos/blob/0.28.0/src/slave/containerizer/mesos/linux_launcher.cpp#L314-L324]
> * 
> [Fetcher|https://github.com/apache/mesos/blob/0.28.0/src/slave/containerizer/fetcher.cpp#L768-L773]



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to