Fix crashes issue due to 0 is a valid index to types_, using invalid index like -1 should give a better/clearer stack trace

This commit is contained in:
ANR2ME committed 2020-08-02 14:02:49 +07:00
1 parent 8886291434
commit 5de2707633
2 files changed
+15 -3

No files matched your search

+6 -1
View File
@@ -251,7 +251,7 @@ void __NetDoState(PointerWrap &p) {
p.Do(apctlThreadID);
}
else {
actionAfterApctlMipsCall = 0;
actionAfterApctlMipsCall = -1;
apctlThreadHackAddr = 0;
apctlThreadID = 0;
}
@@ -442,6 +442,11 @@ void __NetApctlCallbacks()
//if (*error == 0)
*newState = netApctlState;
// Since 0 is a valid index to types_ we use -1 to detects if it was loaded from an old save state
if (actionAfterApctlMipsCall < 0) {
actionAfterApctlMipsCall = __KernelRegisterActionType(AfterApctlMipsCall::Create);
}
// Run mipscall. Should we skipped executing the mipscall if oldState == newState?
for (std::map<int, ApctlHandler>::iterator it = apctlHandlers.begin(); it != apctlHandlers.end(); ++it) {
DEBUG_LOG(SCENET, "ApctlCallback [ID=%i][OldState=%d][NewState=%d][Event=%d][Error=%d][ArgsPtr=%08x]", it->first, *oldState, *newState, *event, *error, it->second.argument);
+9 -2
View File
@@ -131,7 +131,7 @@ void __NetAdhocDoState(PointerWrap &p) {
p.Do(dummyThreadHackAddr);
}
else {
actionAfterMatchingMipsCall = 0;
actionAfterMatchingMipsCall = -1;
dummyThreadHackAddr = 0;
}
if (s >= 3) {
@@ -141,7 +141,7 @@ void __NetAdhocDoState(PointerWrap &p) {
p.Do(matchingThreadHackAddr);
}
else {
actionAfterAdhocMipsCall = 0;
actionAfterAdhocMipsCall = -1;
matchingThreadHackAddr = 0;
}
if (s >= 4) {
@@ -3980,6 +3980,10 @@ void __NetTriggerCallbacks()
//if (/*__KernelGetCurThread() == threadAdhocID &&*/ (!__IsInInterrupt() && __KernelIsDispatchEnabled() && !__KernelInCallback()) && IsAdhocctlInCallback() == 0)
{
// Since 0 is a valid index to types_ we use -1 to detects if it was loaded from an old save state
if (actionAfterAdhocMipsCall < 0) {
actionAfterAdhocMipsCall = __KernelRegisterActionType(AfterAdhocMipsCall::Create);
}
for (std::map<int, AdhocctlHandler>::iterator it = adhocctlHandlers.begin(); it != adhocctlHandlers.end(); ++it) {
DEBUG_LOG(SCENET, "AdhocctlCallback: [ID=%i][EVENT=%i]", it->first, flags);
args[2] = it->second.argument;
@@ -4014,6 +4018,9 @@ void __NetMatchingCallbacks() //(int matchingId)
//if (/*__KernelGetCurThread() == context->matching_thid &&*/ (!__IsInInterrupt() && __KernelIsDispatchEnabled() && !__KernelInCallback()) /*&& !IsMatchingInCallback(context)*/)
{
if (actionAfterMatchingMipsCall < 0) {
actionAfterMatchingMipsCall = __KernelRegisterActionType(AfterMatchingMipsCall::Create);
}
DEBUG_LOG(SCENET, "AdhocMatchingCallback: [ID=%i][EVENT=%i][%s]", args[0], args[1], mac2str((SceNetEtherAddr*)Memory::GetPointer(args[2])).c_str());
AfterMatchingMipsCall* after = (AfterMatchingMipsCall*)__KernelCreateAction(actionAfterMatchingMipsCall);
after->SetData(args[0], args[1], args[2]);