the last bug

Stephen Weeks MLton@sourcelight.com
Tue, 3 Jul 2001 22:56:51 -0700


> Is it just because you are using
> 	frontier > gcState.limit
> to indicate both out of heap space (of course) and pending signal?  If so,
> then the runtime can just clear that flag (i.e., reset the frontier or limit)
> if it is in a critical region.  The reason is that leaving a critical region
> checks (some where else) if there is a pending signal and hence will handle
> the signal code.

That's similar to what I did.  Here is my fix.  Now, leaving a critical section
sets the limit so that at the next limit check the GC will be entered and the
signal handler will be run.

void Thread_atomicBegin() {
	assert(gcState.canHandle >= 0);
 	gcState.canHandle++;
	if (gcState.signalIsPending)
		setLimit(&gcState);			
}

void Thread_atomicEnd() {
	gcState.canHandle--;
	assert(gcState.canHandle >= 0);
	if (gcState.signalIsPending && 0 == gcState.canHandle)
		gcState.limit = gcState.base;
}