[Stackless] slp_kill_tasks_with_stacks is broken

Richard Tew richard.m.tew at gmail.com
Fri Sep 23 07:37:07 CEST 2011


2011/9/22 Kristján Valur Jónsson <kristjan at ccpgames.com>:
> First, off, the code in tasklet_end, which clears the main tasklet, is
> incompatible with the kill_task_with_cstate.
>
> Secondly, the latter function does appear very fragile.

No surprise, really.  I expect that many of the things that contribute
to this are bug fixes and improvements we have made when situations
requiring them to do so have arisen.

> What happens if a
> tasklet that is being killed refuses to die?

This is not our problem.  How would it arise?  A programmer ignoring a
TaskletExit raised on a tasklet?  It seems to me that in this
situation we should detect it, and exit in such a way that it is up to
the programmer to do the right thing if they don't want that to
happen.

> Or creates new tasklets?

Shouldn't this be locked down for a thread when we reach the point
where we are killing the tasklets for that thread?  It seems like a
straightforward choice.

> I
> wonder if we should have a super exception, one that is not catchable as a
> system_exit, to ensure that they die….  Or maybe just require programs not
> to handle tasklet exit or do any magic tasklet stuff during such a handle
> clause.  But that’s a different story.

I do not think we need to make Stackless any more complicated.  Anyone
who is catching TaskletExit and not propagating it upwards is causing
their own problems.  Let's keep it simple.

> What I think should happen is probably something like this.  Assuming that
> kill_tasks_with_cstate can be called with the man and current tasklets still
> valid:
>

0.5) Flag no more created tasklets on the give thread.

> 1)      All runnable tasklets are removed from the runnable queue and
> decrefed, possibly resulting in them dying on their own or being killed,
> leaving only the main tasklet in the queue.
>
> 2)      Then proceed with killing each tasklet.  Now that there is only one
> in the queue left, there is no need to worry about the queue ordering.

Seems like a common sense fix to me.

> Anyway, enough ranting.  I’m not sure what to do here.  It is annoying that
> the main tasklet is cleared like this.  But perhaps it is necessary.
> Perhaps it is necessary to create a new temporary main tasklet…  Who knows.

I had thought you had cleared it in a previous bug fix :p

Cheers,
Richard.



More information about the Stackless mailing list