serenity/Kernel
Robin Burchell d48c73b10a Thread: Cleanup m_blocker handling
The only two places we set m_blocker now are Thread::set_state(), and
Thread::block(). set_state is mostly just an issue of clarity: we don't
want to end up with state() != Blocked with an m_blocker, because that's
weird. It's also possible: if we yield, someone else may set_state() us.

We also now set_state() and set m_blocker under lock in block(), rather
than unlocking which might allow someone else to mess with our internals
while we're in the process of trying to block.

This seems to fix sending STOP & CONT causing a panic.

My guess as to what was happening is this:

    thread A blocks in select(): Blocking & m_blocker != nullptr
    thread B sends SIGSTOP: Stopped & m_blocker != nullptr
    thread B sends SIGCONT: we continue execution. Runnable & m_blocker != nullptr
    thread A tries to block in select() again:
        * sets m_blocker
        * unlocks (in block_helper)
        * someone else tries to unblock us? maybe from the old m_blocker? unclear -- clears m_blocker
        * sets Blocked (while unlocked!)

So, thread A is left with state Blocked & m_blocker == nullptr, leading
to the scheduler assert (m_blocker != nullptr) failing.

Long story short, let's do all our data management with the lock _held_.
2019-07-20 19:31:52 +02:00
..
Arch/i386 Kernel: Move VirtualAddress.h into VM/ 2019-07-09 15:04:45 +02:00
Boot Kernel: Make better use of the multiboot info. 2019-06-02 09:53:42 +02:00
Devices Thread: Return a result from block() indicating why the block terminated 2019-07-20 12:15:24 +02:00
FileSystem Kernel: Some small refinements to the thread blockers. 2019-07-19 13:19:47 +02:00
Net Net: Merge Thread::wait_for_connect into LocalSocket (as the only place that uses it) 2019-07-20 12:15:24 +02:00
TTY AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
VM Kernel: Share the "return to ring 0/3 from signal" trampolines globally. 2019-07-19 17:01:16 +02:00
.bochsrc
.gitignore Meta: Removed all gitignore in the source tree only keeping the root one 2019-06-30 10:41:26 +02:00
Assertions.h Kernel: Move i386.{cpp,h} => Arch/i386/CPU.{cpp,h} 2019-06-07 20:02:01 +02:00
build-image-grub.sh Build: Remove grub from default build process 2019-06-04 07:15:44 -07:00
build-image-qemu.sh Build: Fix incorrect user and group settings for disk image (#280) 2019-07-03 16:57:37 +02:00
build-root-filesystem.sh SystemDialog: Add a new app for showing system dialogs. 2019-07-16 21:41:13 +02:00
CMOS.cpp AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
CMOS.h AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
Console.cpp AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
Console.h AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
DoubleBuffer.cpp AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
DoubleBuffer.h AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
grub.cfg Kernel: Parse cmdline for root filesystem e.g. root=/dev/hda1 2019-06-04 07:14:40 -07:00
init.cpp Finalizer: Don't double-yield 2019-07-20 12:15:24 +02:00
install.sh Build: Install most headers to Root (and libcore.a/libgui.a) 2019-05-17 21:59:48 +02:00
IO.h Kernel: First cut of a sb16 driver 2019-07-13 08:00:24 +02:00
IRQHandler.cpp Kernel: Move PIC.cpp into Arch/i386/ 2019-07-09 15:04:43 +02:00
IRQHandler.h AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
KeyCode.h AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
kmalloc.cpp AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
kmalloc.h AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
KParams.cpp Kernel: Fix KParams parsing with trailing space in kernel cmdline 2019-06-04 07:08:07 -07:00
KParams.h Kernel: Run clang-format on everything. 2019-06-07 11:43:58 +02:00
kprintf.cpp Kernel: Colorize debugger output from the kernel. 2019-06-22 22:45:16 +02:00
KResult.h Kernel: Fix KResultOr move constructor not copying errors. 2019-06-14 06:24:02 +02:00
kstdio.h LibHTML: Make it possible to build LibHTML on the host. 2019-06-22 21:21:57 +02:00
KSyms.cpp AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
KSyms.h AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
linker.ld
Lock.h AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
makeall.sh LibDraw: Introduce (formerly known as SharedGraphics.) 2019-07-18 10:18:16 +02:00
Makefile Kernel: Initial FDC Device Driver (#315) 2019-07-17 15:51:51 +02:00
mkmap.sh
MousePacket.h AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
Multiboot.h AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
PCI.cpp AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
PCI.h AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
Process.cpp Thread: Return a result from block() indicating why the block terminated 2019-07-20 12:15:24 +02:00
Process.h Kernel: Share the "return to ring 0/3 from signal" trampolines globally. 2019-07-19 17:01:16 +02:00
ProcessTracer.cpp AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
ProcessTracer.h Kernel: Move File.{cpp,h} into FileSystem/ 2019-07-09 15:04:45 +02:00
RTC.cpp AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
RTC.h Add clang-format file 2019-05-28 17:31:20 +02:00
run Kernel: First cut of a sb16 driver 2019-07-13 08:00:24 +02:00
Scheduler.cpp Thread: Cleanup m_blocker handling 2019-07-20 19:31:52 +02:00
Scheduler.h AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
SharedBuffer.cpp SharedBuffer: Amend commit 2d4d465206 2019-07-20 12:15:11 +02:00
SharedBuffer.h SharedBuffer: Amend commit 2d4d465206 2019-07-20 12:15:11 +02:00
StdLib.cpp AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
StdLib.h AK: Rename the common integer typedefs to make it obvious what they are. 2019-07-03 21:20:13 +02:00
sync.sh Build: Remove grub from default build process 2019-06-04 07:15:44 -07:00
Syscall.cpp Kernel: Only allow superuser to halt() the system (#342) 2019-07-19 13:08:26 +02:00
Syscall.h Kernel+Userland: Addd reboot syscall (#334) 2019-07-19 09:58:12 +02:00
Thread.cpp Thread: Cleanup m_blocker handling 2019-07-20 19:31:52 +02:00
Thread.h Thread: Cleanup m_blocker handling 2019-07-20 19:31:52 +02:00
UnixTypes.h Kernel: Add support for the WSTOPPED flag to the waitpid() syscall. 2019-07-14 11:35:49 +02:00