HaxeFoundation / HaxeFoundation/hxcpp
PauseForCollect may cause the GC to freeze.
- Dominant language
- C++
- Stars
- 330
- Forks
- 227
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 18
Description
```
void PauseForCollect()
{
if (sgIsCollecting)
CriticalGCError("Bad Allocation while collecting - from finalizer?");
#ifndef HXCPP_SINGLE_THREADED_APP
volatile int dummy = 1;
mBottomOfStack = (int *)&dummy;
CAPTURE_REGS;
#ifdef VerifyStackRead
VerifyStackRead(mBottomOfStack, mTopOfStack)
#endif
mReadyForCollect.Set();
```
** THE COLLECT PROCESS STARTS NOW, AND IF IT FINISHES BEFORE IT REACHES THE NEXT LINE THE PROCESS
IS STUCK **
```
mCollectDone.Wait();
#endif
}
```
My solution. Remove mCollectDone semaphore. Remove ReleaseFromSafe. Replace PauseFor Collect with this code:
```
void PauseForCollect()
{
if (sgIsCollecting)
CriticalGCError("Bad Allocation while collecting - from finalizer?");
#ifndef HXCPP_SINGLE_THREADED_APP
EnterGCFreeZone();
gThreadStateChangeLock->Lock();
ExitGCFreeZoneLocked();
gThreadStateChangeLock->Unlock();
#endif
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.