kernel: extend NullWaitObject fix to WaitSynchronization1 (svc 0x24)

The previous NullWaitObject fix only covered WaitSynchronizationN (0x25).
WaitSynchronization1 (0x24) had the same issue: handle=0 returned
ResultInvalidHandle immediately, crashing any process whose wait handle
had not been populated yet.

Apply the same fix: handle=0 is substituted with a NullWaitObject so the
thread sleeps until the timeout expires and receives ResultTimeout, matching
real hardware behaviour.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Masamune3210 2026-05-14 17:41:14 -05:00
parent 8d9f605fbb
commit f2250fa485

View file

@ -827,7 +827,15 @@ private:
Result SVC::WaitSynchronization1(Handle handle, s64 nano_seconds) {
auto object = kernel.GetCurrentProcess()->handle_table.Get<WaitObject>(handle);
Thread* thread = kernel.GetCurrentThreadManager().GetCurrentThread();
R_UNLESS(object, ResultInvalidHandle);
if (!object) {
// Null handle (0) behaves as a permanently-unavailable object on real hardware —
// the thread sleeps until the timeout expires and then receives ResultTimeout.
if (handle == 0) {
object = std::make_shared<NullWaitObject>(kernel);
} else {
return ResultInvalidHandle;
}
}
LOG_TRACE(Kernel_SVC, "called handle=0x{:08X}({}:{}), nanoseconds={}", handle,
object->GetTypeName(), object->GetName(), nano_seconds);