Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crimson Gem Saga: #8749

Closed
Vyguard opened this issue May 16, 2016 · 4 comments · Fixed by #8934
Closed

Crimson Gem Saga: #8749

Vyguard opened this issue May 16, 2016 · 4 comments · Fixed by #8934

Comments

@Vyguard
Copy link

Vyguard commented May 16, 2016

For what ever reason the game seems to crash at totally random times. Sometimes you can get past it, sometimes you can't. I've run into an instance that I can't seem to get past. The ppsspp crashes, and I just get the nice message for windows to attempt to find a solution. Are there any fixes for this, or any settings that need to be changed? I'm running it on the ppsspp64 all the other games run perfectly fine. I'm also running default settings for the program.

@unknownbrackets
Copy link
Collaborator

unknownbrackets commented Aug 21, 2016

This was reported here:
http://forums.ppsspp.org/showthread.php?tid=1243&pid=106156#pid106156

As a regression from 879baec. We weren't sure why, though - this just suggested it was somehow timing related.

@LunaMoo created a cheat workaround, but of course that's not really a full solution.

Looking into it further, the problem seems to be io timing related (noting for #7647). By increasing the seek delay from 0.1ms to 0.3ms, for example, I'm also able to avoid the problem. More tests may be needed, but changing the seek latency is probably the "correct" fix here.

For more technical detail:

  1. The game creates a thread, th_load_voice.
  2. th_load_voice locks a mutex and seeks in a file.
  3. user_main calls memset 5 times on small amounts of bytes (about 0x900 total.)
  4. th_load_voice awakes from sleep, unlocks the mutex, then locks it again.
  5. A memory read gets a null pointer and crashes.

I haven't found the exact point where things diverge, but making memset take longer basically means the 5 memsets are not done before th_load_voice wakes up. Ultimately, the game seems to be depending on a race between the user_main thread and th_load_voice. Making memset take longer fixed the winner of the race, but changing seek latency has the same effect (the other way) and seems more correct.

-[Unknown]

@unknownbrackets
Copy link
Collaborator

It seems even 0.101ms latency instead of 0.1ms will work. It's very possible that 0.1ms is just the wrong value and slightly too low, but I need to do more tests to try to verify. Maybe we should change it for now, although I'm not sure if it fixes this issue everywhere.

The change is (all occurrences in sceIo.cpp):

return hleDelayResult(result, "io seek", 100);

To:

return hleDelayResult(result, "io seek", 101);

-[Unknown]

@unknownbrackets unknownbrackets added the Needs hardware testing Testing on a real device needed to determine correct behavior. label Aug 22, 2016
@y-salnikov
Copy link

101 does nothing but 200 is work for me. Don't know what i'm doing though.

unknownbrackets added a commit to unknownbrackets/ppsspp that referenced this issue Aug 27, 2016
This doesn't seem to reschedule, must've measured wrong in hrydgard#939.

Fixes hrydgard#8749.
@unknownbrackets
Copy link
Collaborator

Turns out it was actually too high - it works consistently for me without the too-large delay.

-[Unknown]

@unknownbrackets unknownbrackets removed the Needs hardware testing Testing on a real device needed to determine correct behavior. label Aug 27, 2016
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 a pull request may close this issue.

3 participants