Always perform thread cleanup on MainThread stack.

The thread cleanup was being performed on whatever thread stack was
next in the list.  However, with high debugging this causes spurious
_free() debug messages to show up in random threads which can be
confusing when analyzing the debug output.  So, always run
__end_thread() on the MainThread stack to prevent this confusion.

Signed-off-by: Kevin O'Connor <>
1 file changed