Fix a very rare hang on sgen.
authorRodrigo Kumpera <kumpera@gmail.com>
Mon, 21 May 2012 15:29:53 +0000 (12:29 -0300)
committerRodrigo Kumpera <kumpera@gmail.com>
Mon, 21 May 2012 15:37:12 +0000 (12:37 -0300)
commit8917af002e92d7a47fbd9acdbbe0d0d3c640f951
tree4d1fd2a2dda889e60d62b973866f6b70a4091511
parent5dc6a43b84cbba5fa2c7d91160da676a6d8775ed
Fix a very rare hang on sgen.

* sgen-gc.c (restart_threads_until_none_in_managed_allocator):
When suspending threads, if a given thread was suspended on
a gc unsafe point we restart it until it land on a safe zone.

Since we restart the thread, it might die before we get the chance
to suspend it again, we take this into account except when waiting
for acks. We mistakenly waited for the same number of acks of the
restart step. It could have been reduced if a thread died.

This bug is very very hard to hit as it only happens on linux,
requires that a thread on an unsafe point dies right after been
restarted and it must not be a managed thread as those must take
the GC lock while cleaning up.

This sums up to a mostly theoretical bug that someone might
have observed once in the wild. We're better fixing it now
since further optimization work might make it easier to hit.
mono/metadata/sgen-gc.c