MCPcopy Create free account
hub / github.com/apache/mesos / generateJeprofFile

Function generateJeprofFile

3rdparty/libprocess/src/memory_profiler.cpp:307–333  ·  view source on GitHub ↗

TODO(alexr): Consider making this asynchronous.

Source from the content-addressed store, hash-verified

305
306// TODO(alexr): Consider making this asynchronous.
307Try<Nothing> generateJeprofFile(
308 const string& inputPath,
309 const string& options,
310 const string& outputPath)
311{
312 // As jeprof doesn't have an option to specify an output file, we actually
313 // cannot use `os::spawn()` here.
314 // Note that the three parameters *MUST NOT* be controllable by the user
315 // accessing the HTTP endpoints, otherwise arbitrary shell commands could be
316 // trivially injected.
317 // Apart from that, we dont need to be as careful here as with the actual
318 // heap profile dump, because a failure will not crash the whole process.
319 Option<int> result = os::system(strings::format(
320 "jeprof %s /proc/self/exe %s > %s",
321 options,
322 inputPath,
323 outputPath).get());
324
325 if (result != 0) {
326 return Error(
327 "Error trying to run jeprof. Please make sure that jeprof is installed"
328 " and that the input file contains data. For more information, please"
329 " consult the log files of this process");
330 }
331
332 return Nothing();
333}
334
335
336// TODO(bevers): Implement `http::Request::extractFromRequest<T>(string key)`

Callers 2

downloadGraphProfileMethod · 0.85

Calls 5

formatFunction · 0.85
NothingClass · 0.85
systemFunction · 0.50
ErrorClass · 0.50
getMethod · 0.45

Tested by

no test coverage detected