Skip to content

R&C menu Wait: Unreachable code fix (on Windows)#4045

Open
w1naenator wants to merge 21 commits into
shadps4-emu:mainfrom
w1naenator:R&C-menu-uc-fix-win
Open

R&C menu Wait: Unreachable code fix (on Windows)#4045
w1naenator wants to merge 21 commits into
shadps4-emu:mainfrom
w1naenator:R&C-menu-uc-fix-win

Conversation

@w1naenator
Copy link
Copy Markdown
Contributor

@w1naenator w1naenator commented Feb 17, 2026

kernel: Enhance condition variable wait and signal handling with improved timeout logic and error checks

@w1naenator
Copy link
Copy Markdown
Contributor Author

I do not know whether the issue [Debug] <Critical> (Job Thread Lo 1) condvar.cpp:144 Wait: Unreachable code! occurs on Linux or macOS, but on Windows with my hardware it does appear. This patch fixes it.
image

@StevenMiller123
Copy link
Copy Markdown
Collaborator

I mean, removing the unreachable does fix the issue, but the problem we'd like to figure out is why we have spurious wakeups in the first place

@w1naenator
Copy link
Copy Markdown
Contributor Author

w1naenator commented Feb 17, 2026

Agree that removing UNREACHABLE is only a correctness fix for condvar semantics. I also addressed a concrete wake source: signal-to-thread without queue membership validation combined with an unchecked SleepqRemove. That combination could wake a thread without a matching dequeue. With the membership check and proper handling of removed == 0, I prevent that path while still allowing legitimate spurious wakeups.
I will add temporary debug logs on the spurious/stray wakeup branch to prove whether any remain and from which path.

break;
}
UNREACHABLE();
// Spurious/stray wakeup: keep waiting until dequeued, canceled, or timed out.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember talking with @raphaelthegreat before that this unreachable should be here, we really should not be hitting this case. But I didn't figure out why it was being hit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried to figure this out as well a few times but couldn't. Honestly might be best to comment it out at this point, its doing more harm than good and pro badly is a spurious wakeup

@w1naenator
Copy link
Copy Markdown
Contributor Author

@StevenMiller123, @georgemoralis. With GPU page protection disabled and several code modifications applied, I can reach in-game in Ratchet & Clank on Windows.

@w1naenator
Copy link
Copy Markdown
Contributor Author

image

@StevenMiller123
Copy link
Copy Markdown
Collaborator

I mean, Ratchet & Clank is ingame on main too, it just takes luck.
I'll wait for more relevant reviewers to take a look, I haven't dabbled much with our pthreads code.

@w1naenator
Copy link
Copy Markdown
Contributor Author

I cant reach ingame on windows with my hw.

@w1naenator
Copy link
Copy Markdown
Contributor Author

With GPU page protection disabled, it loads stably, but the FPS is low.

@w1naenator
Copy link
Copy Markdown
Contributor Author

Stable ingame on CPU Model: Intel(R) Core(TM) i9-10885H CPU @ 2.40GHz + Quadro T2000 with Max-Q Design
Screenshot 2026-04-09 175427

@georgemoralis
Copy link
Copy Markdown
Collaborator

clang issue :D

@w1naenator
Copy link
Copy Markdown
Contributor Author

Also with a “new generation” Intel CPU - 12th Gen Intel® Core™ i9-12900H and NVIDIA GeForce RTX 3070 Ti Laptop GPU - but, of course, with broken textures. Textures are also broken on all builds on my hardware, if I’m lucky enough to get in-game.
Screenshot 2026-04-09 175303

@bigol83
Copy link
Copy Markdown
Contributor

bigol83 commented Apr 9, 2026

Also with a “new generation” Intel CPU - 12th Gen Intel® Core™ i9-12900H and NVIDIA GeForce RTX 3070 Ti Laptop GPU - but, of course, with broken textures. Textures are also broken on all builds on my hardware, if I’m lucky enough to get in-game. Screenshot 2026-04-09 175303

hello
can you reach ingame on 1.09 with your 12th Gen Intel cpu? I see your screenshot shows you are ingame with 1.00. I just want to confirm if it's not just my issue. I also have 12th Gen Intel cpu and I cannot reach ingame with 1.09 too, just with 1.00.

@w1naenator
Copy link
Copy Markdown
Contributor Author

Also with a “new generation” Intel CPU - 12th Gen Intel® Core™ i9-12900H and NVIDIA GeForce RTX 3070 Ti Laptop GPU - but, of course, with broken textures. Textures are also broken on all builds on my hardware, if I’m lucky enough to get in-game. Screenshot 2026-04-09 175303

hello can you reach ingame on 1.09 with your 12th Gen Intel cpu? I see your screenshot shows you are ingame with 1.00. I just want to confirm if it's not just my issue. I also have 12th Gen Intel cpu and I cannot reach ingame with 1.09 too, just with 1.00.

Ou, good catch! I will test later!

@w1naenator
Copy link
Copy Markdown
Contributor Author

Also with a “new generation” Intel CPU - 12th Gen Intel® Core™ i9-12900H and NVIDIA GeForce RTX 3070 Ti Laptop GPU - but, of course, with broken textures. Textures are also broken on all builds on my hardware, if I’m lucky enough to get in-game. Screenshot 2026-04-09 175303

hello can you reach ingame on 1.09 with your 12th Gen Intel cpu? I see your screenshot shows you are ingame with 1.00. I just want to confirm if it's not just my issue. I also have 12th Gen Intel cpu and I cannot reach ingame with 1.09 too, just with 1.00.

I confirm that after updating to v1.09, it crashes again. I will investigate the cause.

@w1naenator
Copy link
Copy Markdown
Contributor Author

@bigol83, can you test again?

@bigol83
Copy link
Copy Markdown
Contributor

bigol83 commented Apr 10, 2026

@bigol83, can you test again?

it does crash when trying to reach ingame with 1.09
it has not condvar crashes though

@w1naenator
Copy link
Copy Markdown
Contributor Author

can you share log?

@w1naenator
Copy link
Copy Markdown
Contributor Author

@bigol83, can you test again?

it does crash when trying to reach ingame with 1.09 it has not condvar crashes though

Hmm, Github copy fails, my local build working, thats strange, can you try attached file?
shadps4.zip

@bigol83
Copy link
Copy Markdown
Contributor

bigol83 commented Apr 10, 2026

@bigol83, can you test again?

it does crash when trying to reach ingame with 1.09 it has not condvar crashes though

Hmm, Github copy fails, my local build working, thats strange, can you try attached file? shadps4.zip

Reaches ingame 🎉
immagine

but it has more vertex explosions

@w1naenator
Copy link
Copy Markdown
Contributor Author

@bigol83, can you test again?

it does crash when trying to reach ingame with 1.09 it has not condvar crashes though

Hmm, Github copy fails, my local build working, thats strange, can you try attached file? shadps4.zip

Reaches ingame 🎉 immagine

but it has more vertex explosions

I am working this direction.

@w1naenator
Copy link
Copy Markdown
Contributor Author

@bigol83, You can enable readbacks, linear image readbacks and direct memory access in per game config, then shadows and reflections should appear.

@w1naenator
Copy link
Copy Markdown
Contributor Author

@bigol83, if you want to see correct geometry, just set the launcher to Windows 7 compatibility mode and see the magic.

@bigol83
Copy link
Copy Markdown
Contributor

bigol83 commented Apr 10, 2026

@bigol83, if you want to see correct geometry, just set the launcher to Windows 7 compatibility mode and see the magic.

immagine ❤️

@georgemoralis
Copy link
Copy Markdown
Collaborator

needs rebase and i am not sure about this , need a new review circle

@w1naenator
Copy link
Copy Markdown
Contributor Author

needs rebase and i am not sure about this , need a new review circle

I will do it tomorrow!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants