[Stackless] st.serial --> st.serial_last_jump patch

Jeff Senn senn at maya.com
Tue Nov 24 20:30:59 CET 2009

Ok ... it turns out (not surprisingly) to be more complicated than I thought.

I'm using preemptive scheduling (stackless.run(interval)) to run some tasklets
for awhile, return out of the embedded interpreter, and come back later and
run some more.  When I "come back later"... I wind up with a different 
"main" tasklet (i.e. the first main tasklet has previously returned out of it's stack).  

When I start scheduling, this causes a hard-switch into the previously created tasklets
because they were on a "different stack" (even though they won't ever use anything
on the cstack)
[Note: I'd like to avoid this... so maybe I'll reorganize... but meanwhile...]
the slp_transfer notes the serial of the *old* main tasklet in last_jump...

and when the return after the stackless.run(i) happens it attempts to 
slp_transfer_return to a previous main tasklet (which is now gone)

 1) something is failing to mark serial_last_jump in the switch back to the
    *new* main tasklet (when stackless.run(i) returns)
 2) something I'm doing is wrong-headed

I think it's #1... because I believe what should happen is that the *new*
main tasklet should just return (out of *it's* stack) -- nothing should
ever return (again) from the prior stack (it should just be left around so
the tasklets can run).

I hope this is lucid...it's been quite a while since I looked at 
stackless internals...and I'm trying to do too much at once today...


On Nov 24, 2009, at 10:17 AM, Kristján Valur Jónsson wrote:

> Interesting.  My crash that I fixed with the chance was precisely because a _necessary_ slp_transfer_return() was missed because stackless thought that it was in the correct stack.
> An extra slp_transfer_return() should be ok regardless, _if_ your are in fact returning from the _correct_ main tasklet. 
> Is there a chance that you can create a mini-app that exhibits this behaviour?
> K
>> -----Original Message-----
>> From: stackless-bounces at stackless.com [mailto:stackless-
>> bounces at stackless.com] On Behalf Of Jeff Senn
>> Sent: 24. nóvember 2009 14:39
>> To: stackless list
>> Subject: [Stackless] st.serial --> st.serial_last_jump patch
>> Kristjan (or anyone else if you've looked at it)-
>> RE: Your serial_last_jump patch...
>> In my attempt to go to 2.6.4 I included your patch -- but it causes a
>> crash
>> (that goes away when I revert it out).  I haven't debugged much -- but
>> what
>> appears to be happening is that serial_last_jump != serial in the main
>> tasklet
>> cleanup causing an unnecessary slp_transfer_return... (in my case there
>> is
>> only soft-switching and one thread that is known to python).
>> It does happen in a case that one would not normally find:  in
>> particular
>> I have stackless embedded in an app that make an instance of the
>> interpreter
>> and "feeds" it work to do... occasionally when it's "done",
>> the main tasklet exits back to the controlling program -- but the
>> interpreter
>> can be called  again in the future -- creating a new main
>> tasket...etc...
>> It is one one of these subsequent main tasklet exits that the
>> unnecessary
>> slp_transfer_return causes a crash.
>> I'll continue to debug at some rate, but if you have some idea what
>> might be
>> wrong, please let me know...
>> _______________________________________________
>> Stackless mailing list
>> Stackless at stackless.com
>> http://www.stackless.com/mailman/listinfo/stackless

More information about the Stackless mailing list