Fix a deadlock, and possibly other problems
authorSimon Marlow <marlowsd@gmail.com>
Tue, 26 Jan 2010 15:00:37 +0000 (15:00 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Tue, 26 Jan 2010 15:00:37 +0000 (15:00 +0000)
commit3b97d0d07bad34afb18fb8b120b037e0f91fe9ee
tree81f428538780e64b50443029b20d9f6d2abface8
parent65ac2f4cefcea7ca78a65ca22889b51b5a27d1f0
Fix a deadlock, and possibly other problems
After a bound thread had completed, its TSO remains in the heap until
it has been GC'd, although the associated Task is returned to the
caller where it is freed and possibly re-used.

The bug was that GC was following the pointer to the Task and updating
the TSO field, meanwhile the Task had already been recycled (it was
being used by exitScheduler()). Confusion ensued, leading to a very
occasional deadlock at shutdown, but in principle it could result in
other crashes too.

The fix is to remove the link between the TSO and the Task when the
TSO has completed and the call to schedule() has returned; see
comments in Schedule.c.
rts/Schedule.c