1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +02:00

Allow BfpThread_GetIntRegisters to fail without crashing

This commit is contained in:
Brian Fiete 2020-11-22 07:56:36 -08:00
parent b60c247f1a
commit 3adf9a144e
3 changed files with 14 additions and 1 deletions

View file

@ -602,6 +602,7 @@ BFGC::BFGC()
mPaused = false;
mShutdown = false;
mForceDecommit = false;
mCollectFailed = false;
mLastCollectFrame = 0;
mSkipMark = false;
mGracelessShutdown = false;
@ -979,6 +980,11 @@ void BFGC::SweepSpan(tcmalloc_obj::Span* span, int expectedStartPage)
mCurSweepFoundPermanentCount++;
int markId = objectFlags & BF_OBJECTFLAG_MARK_ID_MASK;
if ((mCollectFailed) && (markId != mCurMarkId))
{
obj->mObjectFlags = (BfObjectFlags)((obj->mObjectFlags & ~BF_OBJECTFLAG_MARK_ID_MASK) | mCurMarkId);
markId = mCurMarkId;
}
BF_ASSERT(markId != invalidMarkId);
@ -1471,6 +1477,12 @@ bool BFGC::ScanThreads()
BP_ZONE("BfpThread_GetIntRegisters");
BfpThread_GetIntRegisters(thread->mThreadHandle, &stackPtr, regVals, &regValCount, &threadResult);
}
if (threadResult != BfpThreadResult_Ok)
{
mCollectFailed = true;
return false;
}
BF_ASSERT(threadResult == BfpThreadResult_Ok);
void** threadLoadAddressMap = (void**)((_TEB*)thread->mTEB)->ThreadLocalStorage;
@ -2388,6 +2400,7 @@ void BFGC::PerformCollection()
#else
Beefy::AutoCrit autoCrit(mCritSect);
mAllocSinceLastGC = 0;
mCollectFailed = false;
// This was old "emergency" debugging code to make sure we weren't doing a malloc in the GC code,
// but it's a multi-threaded race condition

View file

@ -288,6 +288,7 @@ public:
bool mPaused;
bool mShutdown;
bool mWaitingForGC; // GC.Collect sets this
bool mCollectFailed;
int mAllocSinceLastGC; // Added to on alloc and subtracted from on nursery cleanup
int mFreeSinceLastGC;

View file

@ -2190,7 +2190,6 @@ BFP_EXPORT void BFP_CALLTYPE BfpThread_GetIntRegisters(BfpThread* thread, intptr
if (!success)
{
int error = GetLastError();
BF_DBG_FATAL("Failed BfpThread_GetIntRegisters");
OUTRESULT(BfpThreadResult_UnknownError);
return;
}