[Stackless] Stackless breaks generators that do not yield

Christian Tismer tismer at tismer.com
Sat Mar 8 15:08:20 CET 2003

Sune Kirkeby wrote:
> Hello all,
> It seems there is an INCREF/DECREF-mismatch in stackless when you
> have generators that do not yield.  If you build stackless
> --with-pydebug you'll get the following badness when running the
> attached python-program:
> [sune at melpomene:/usr/src/stackless-python/stackless/src]$./python bloop
> Adding parser accelerators ...
> Done.
> Python/ceval.c:165 negative ref count -1
> Python/ceval.c:129 negative ref count -1
> Traceback (most recent call last):
>   File "bloop", line 5, in ?
>     g().next()
> StopIteration
> [5812 refs]
> python: Objects/frameobject.c:510: PyFrame_Fini: Assertion `numfree == 0' failed.
> Aborted
> [sune at melpomene:/usr/src/stackless-python/stackless/src]$
> Stock Python 2.2.2 does not produce the "negative ref count"s and
> also does not hit the PyFrame_Fini assertion.  That's as far as I
> have gotten sofar, not knowing much about Python internals, I hope
> someone here will be able to track the critter down.

I believe you are referring to the current CVS version?
Thank you very much, this fits nicely in the set of
problems which I'm just working on.
I'm currently struggling with refcounts. The policy of
decreffing frames has changed quite much since generators
were introduced. Before, a frame derefenced itself.
Now it is done by the caller, and the callers of
generator frames know when to drop the frame and when not.

With introduction of Stackless 1.0 switching, I get into
trouble since there is no longer such a thing like a caller,
and I tried to implement this using a special flag
whether a frame is "done". This is probably still wrong in
a number of places, and I don't like the solution very
much. I also have a bug whitch so-called CFrames.

Maybe I should revert the refcount thing and find some
other way to handle this.

This problem blocks me since weeks, and I could really need
somebody to have a look, and maybe suggest a better

Thanks again - 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