Skip to content

Commit 4e87d1f

Browse files
Gliniakgibbed
authored andcommitted
[Kernel/Thread] Set TLS slot to 0 while freeing
1 parent e55cb73 commit 4e87d1f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/xenia/kernel/kernel_state.cc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,17 @@ void KernelState::set_process_type(uint32_t value) {
138138

139139
uint32_t KernelState::AllocateTLS() { return uint32_t(tls_bitmap_.Acquire()); }
140140

141-
void KernelState::FreeTLS(uint32_t slot) { tls_bitmap_.Release(slot); }
141+
void KernelState::FreeTLS(uint32_t slot) {
142+
const std::vector<object_ref<XThread>> threads =
143+
object_table()->GetObjectsByType<XThread>();
144+
145+
for (const object_ref<XThread>& thread : threads) {
146+
if (thread->is_guest_thread()) {
147+
thread->SetTLSValue(slot, 0);
148+
}
149+
}
150+
tls_bitmap_.Release(slot);
151+
}
142152

143153
void KernelState::RegisterTitleTerminateNotification(uint32_t routine,
144154
uint32_t priority) {

0 commit comments

Comments
 (0)