if one of the fibers which shares a stack with others exits, make sure we don't try to save it stack state later.
--- a/model/pthread-fiber-manager.cc Wed Oct 06 15:20:49 2010 +0200
+++ b/model/pthread-fiber-manager.cc Wed Oct 06 16:38:49 2010 +0200
@@ -160,14 +160,17 @@
struct PthreadFiber *previous = self->m_jumpTarget->previous;
if (previous != next)
{
- // first, we save the stack of previous.
- if (previous->stack_copy == 0)
+ if (previous != 0)
{
- previous->stack_copy = malloc (previous->thread->stack_size);
+ // first, we save the stack of previous.
+ if (previous->stack_copy == 0)
+ {
+ previous->stack_copy = malloc (previous->thread->stack_size);
+ }
+ memcpy (previous->stack_copy,
+ previous->stack_bounds.GetStart (),
+ previous->stack_bounds.GetSize ());
}
- memcpy (previous->stack_copy,
- previous->stack_bounds.GetStart (),
- previous->stack_bounds.GetSize ());
// then, we restore the stack of next
memcpy (next->stack_bounds.GetStart (),
next->stack_copy,
@@ -406,6 +409,10 @@
NS_ASSERT (status == 0);
delete fiber->thread;
}
+ else if (fiber->thread->previous == fiber)
+ {
+ fiber->thread->previous = 0;
+ }
if (fiber->stack_copy != 0)
{
free (fiber->stack_copy);