the last bug

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


> I still don't get the problem: the GC handler should first look if space is
> exausted, and if so do a GC.  Then on the way out (after the above) look if
> there is a signal and we are not in a critical section: if so run the signal
> handler.  Also the code to leave a critical section must look if a signal is
> pending, and if so run the handler.  Doesn't that solve everything?

Here is LimitCheck in ccodegen.h.

#define LimitCheck(frameSize, ret, b, other)					\
	do {									\
		declareFirst;							\
										\
		if (GC_EVERY_CHECK						\
		or (GC_FIRST_CHECK and gc_first)				\
		or frontier + (b) > gcState.limit				\
		or (other)) {							\
			do {							\
				uint	bytes = b;				\
										\
				InvokeRuntime					\
					(GC_gc(&gcState, bytes,			\
						GC_EVERY_CHECK or		\
						(GC_FIRST_CHECK and gc_first),	\
						__FILE__, __LINE__),		\
					frameSize, ret);			\
			} while (frontier + (b) > gcState.limit)		\
			clearFirst;						\
		}								\
		assert(gcState.stackBottom <= stackTop + WORD_SIZE);		\
	} while (0)

If we are in a critical section and a signal is pending (so that the gc doesn't
run the signal handler, the do-while will loop forever.

But my fixed seems to have worked.