1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:57:45 +00:00

Kernel: Fix intermittent assertion failure in sys$exec()

While setting up the main thread stack for a new process, we'd incur
some zero-fill page faults. This was to be expected, since we allocate
a huge stack but lazily populate it with physical pages.

The problem is that page fault handlers may enable interrupts in order
to grab a VMObject lock (or to page in from an inode.)

During exec(), a process is reorganizing itself and will be in a very
unrunnable state if the scheduler should interrupt it and then later
ask it to run again. Which is exactly what happens if the process gets
pre-empted while the new stack's zero-fill page fault grabs the lock.

This patch fixes the issue by creating new main thread stacks before
disabling interrupts and going into the critical part of exec().
This commit is contained in:
Andreas Kling 2019-12-18 23:03:23 +01:00
parent 1d4d6f16b2
commit 3012b224f0
3 changed files with 26 additions and 8 deletions

View file

@ -351,7 +351,8 @@ public:
void set_default_signal_dispositions();
void push_value_on_stack(u32);
void make_userspace_stack_for_main_thread(Vector<String> arguments, Vector<String> environment);
u32 make_userspace_stack_for_main_thread(Vector<String> arguments, Vector<String> environment);
void make_thread_specific_region(Badge<Process>);