[Stackless] Re: Stackless bug/typo

Christian Tismer tismer at tismer.com
Tue Jun 18 15:32:45 CEST 2002

Jeff Senn wrote:

>>Thanks a lot, and please tell me about the scheduler, I am
>>a bit undecided what kind to build first.
> What I did to "break the ice" was to simply (and somewhat naively) put
> in a call to slp_schedule_task the same place as the interpreter
> thread lock release/acquire in ceval.c.  Also I added a routine to
> set/clear the slicing_lock flag in the slp_state (so I could do atomic
> sections ala continuation.continuation_uthread_lock).

Ok, that's partially right, partially wrong.

> Note: you probably intended this to be an internal flag for atomic
> sections and there should be another one for a scheduler lock.

Exactly. Never touch the slicing_lock, unless you know that
you can do it. It's only intent is to protect tkinter. Tkinter
does calls to Tcl which does callbacks into Python, passing
data that is livin on the stack.
slicing_lock is intended to prevend the "stack slicing" while
in Tkinter.
This has nothing to do with switch locking. It seems to be
pretty ok to switch tasklets inside of Tkinter, since we
completely switch the context. The stack slicing happens
while in the *same* context.

> And... it works... for all relatively simple tests I can build.
> However, my complex case of an irreducible application (with Tk and
> network I/O running in separate, real threads) crashes fairly quickly.
> Initially the crash was in GC -- I've compiled without cycle_gc and
> it still crashes.  Given the only somewhat random symptoms I'm
> guessing it is a memory corruption caused by a incorrectly reference-
> counted object. Or some bad interaction with threads. 

No, I think (hope) it is from touhing the slicing_lock.
What should go in there is a switching_lock (preferably just
a bit, but I have to do clean-ups, anyway) which allows to
prevend auto-switching.
I guess your program will run if you just ignore the
slicing_lock completely and allow switching all the time.

ciao - chris

Christian Tismer             :^)   <mailto:tismer at tismer.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34  home +49 30 802 86 56  pager +49 173 24 18 776
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/

Stackless mailing list
Stackless at www.tismer.com

More information about the Stackless mailing list