Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bac72c88 authored by Daniel Colascione's avatar Daniel Colascione Committed by Gerrit Code Review
Browse files

Merge "Add explanation for clone use"

parents 99888af9 b650aef2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ bool PtracerThread::Start() {
    return (*reinterpret_cast<std::function<int()>*>(arg))();
  };

  // See README.md for why we create the child process this way
  child_pid_ = clone(proxy, stack_->top(), CLONE_VM | CLONE_FS | CLONE_FILES /*|CLONE_UNTRACED*/,
                     reinterpret_cast<void*>(&func_));
  if (child_pid_ < 0) {
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ The sequence of steps required to perform a leak detection pass is divided into

 1. *Original process*: Leak detection is requested by calling `GetUnreachableMemory()`
 2. Allocations are disabled using `malloc_disable()`
 3. The collection process is spawned.  The collection process is similar to a normal `fork()` child process, except that it shares the address space of the parent - any writes by the original process are visible to the collection process, and vice-versa.
 3. The collection process is spawned.  The collection process, created using clone, is similar to a normal `fork()` child process, except that it shares the address space of the parent - any writes by the original process are visible to the collection process, and vice-versa. If we forked instead of using clone, the address space might get out of sync with observed post-ptrace thread state, since it takes some time to pause the parent.
 4. *Collection process*: All threads in the original process are paused with `ptrace()`.
 5. Registers contents, active stack areas, and memory mapping information are collected.
 6. *Original process*: Allocations are re-enabled using `malloc_enable()`, but all threads are still paused with `ptrace()`.