title: "Red zone": Memory management on linux
body: <p>Regarding memory management on linux:</p>
  <p>On linux, there is a non-volatile area called &quot;the red zone&quot;, an area below the stack (you reach it when pushing onto the stack), that is reserved and safe to use (that is, the OS will not overwrite it).</p>
  <p>The questions are:</p>
  <ol>
  <li><p>How big is the area beyond (after) the red zone, that CAN be overwritten (is volatile), before you can safely place data again (using an mmap call or similar)? (E.g. for allocating memory for a coroutine stack.)</p>
  </li>
  <li><p>What could possibly alter this volatile memory area? Wikipedia lists &quot;interrupt/exception/signal handlers&quot;.</p>
  </li>
  </ol>
  <p>Assume a language that doesn't have language-level exception handling (e.g. assembly). Seems like &quot;exception handlers&quot; are just signal handlers for hardware exceptions such as divide by zero. If so, we can reduce it to &quot;interrupt/signal handlers&quot;.</p>
  <p>Does the kernel simply write into user-space memory on an interrupt? That seems &quot;wrong&quot;. Shouldn't each thread have its own kernel stack in kernel space?</p>
  <ol start="3">
  <li>Regarding signals:
  &quot;If a signal handler is not installed for a particular signal, the default handler is used.&quot;</li>
  </ol>
  <p>Does this apply even in assembly (does the kernel supply a default handler), or is the &quot;default handler&quot; really just a part of the c runtime?</p>