summaryrefslogtreecommitdiff
path: root/Kernel/Thread.h
diff options
context:
space:
mode:
authorTom <tomut@yahoo.com>2020-09-07 08:31:00 -0600
committerAndreas Kling <kling@serenityos.org>2020-09-07 16:49:19 +0200
commitc3d231616c1d20309b2b568f383fbcb736887dad (patch)
treea2a84f86d0cf91f7baf77616dca5dbeda5fd7e6d /Kernel/Thread.h
parentf1a65d1d70da913af961761d3d2aa53455bd1cc0 (diff)
downloadserenity-c3d231616c1d20309b2b568f383fbcb736887dad.zip
Kernel: Fix crash when delivering signal to barely created thread
We need to wait until a thread is fully set up and ready for running before attempting to deliver a signal. Otherwise we may not have a user stack yet. Also, remove the Skip0SchedulerPasses and Skip1SchedulerPass thread states that we don't really need anymore with software context switching. Fixes the kernel crash reported in #3419
Diffstat (limited to 'Kernel/Thread.h')
-rw-r--r--Kernel/Thread.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/Kernel/Thread.h b/Kernel/Thread.h
index 316fe3daa3..3e72bdd8ec 100644
--- a/Kernel/Thread.h
+++ b/Kernel/Thread.h
@@ -114,8 +114,6 @@ public:
Invalid = 0,
Runnable,
Running,
- Skip1SchedulerPass,
- Skip0SchedulerPasses,
Dying,
Dead,
Stopped,
@@ -417,7 +415,7 @@ public:
ShouldUnblockThread dispatch_one_pending_signal();
ShouldUnblockThread dispatch_signal(u8 signal);
- bool has_unmasked_pending_signals() const { return m_pending_signals & ~m_signal_mask; }
+ bool has_unmasked_pending_signals() const { return m_have_any_unmasked_pending_signals.load(AK::memory_order_consume); }
void terminate_due_to_signal(u8 signal);
bool should_ignore_signal(u8 signal) const;
bool has_signal_handler(u8 signal) const;
@@ -587,6 +585,7 @@ private:
bool m_dump_backtrace_on_finalization { false };
bool m_should_die { false };
bool m_initialized { false };
+ Atomic<bool> m_have_any_unmasked_pending_signals { false };
OwnPtr<ThreadTracer> m_tracer;