0

I have a theoretical question, What would happen if I clean up all the swap space while running, Would the operating system crash because of page faults that would happen in the kernel?

2
  • What do you mean by "clean up"? Turn swap off? Overwrite with random values?
    – Jens
    Apr 9, 2016 at 20:14
  • Overwrite with random values
    – Lee
    Apr 10, 2016 at 7:05

2 Answers 2

6

Overwriting swap with random values is equivalent to overwriting process images in memory with random values.

If a text segment with random values is executed, the most likely result is process termination due to an illegal instruction (signal SIGILL).

If a data segment with random values is read, the result is most likely process termination due to a segmentation fault (signal SIGSEGV), because pointers will point outside the process's address space. Note that pointers are data, just like scalars. Especially the stack usually contains several pointers; when a return instruction is executed, a random stack entry causes a jump to a random address.

2
  • You refer to pointers, not content. Perhaps you can clarify that in your good answer.
    – Nils
    Apr 10, 2016 at 12:57
  • @Nils Thanks for the suggestion. I've added a bit more to clarify.
    – Jens
    Apr 10, 2016 at 14:42
4

If you just mean running "swapoff -a" when you say "clean up", then no.

If you corrupt/overwrite the swap device/file, an application that gets swapped back in (with corrupted data) is very likely to crash, yes. The kernel does not get swapped out, so the "system" would not crash.

2
  • The kernel does not get swapped out at all? Is it possible to configure that?
    – Lee
    Apr 10, 2016 at 7:02
  • @Lee No, because the kernel does the swapping. Otherwise you would have a chicken-and-egg problem.
    – Jens
    Apr 10, 2016 at 10:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .