bug in limit checks and threads

Stephen Weeks MLton@sourcelight.com
Mon, 2 Oct 2000 16:13:02 -0700 (PDT)


There is currently a bug in the way thread switching is handled.  The problem is
caused by the fact that limit check points are the same as context switch
points.  The bug is that a thread checks that there is enough space available
before switching to another thread and not when it resumes.  Hence there is no
guarantee that there is enough space when the thread resumes.  There are three
possible fixes I see to this problem.

1. Save the bytesRequested as part of the gc state and have the gc check it
   upon resumption.
2. Have the LimitCheck code include a loop that checks again, upon return from
   the GC.
3. Have some global max over all (fixed-size) limit checks that the GC
   guarantees is available upon thread resumption.  Disallow thread switches
   at variable-sized limit check points.

Any opinions on which way is the right way to go?  Other solutions?