This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author larry
Recipients larry
Date 2021-04-19.23:00:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1618873210.06.0.38844739847.issue43891@roundup.psfhosted.org>
In-reply-to
Content
I'm working on a branch to implement PEP 649:

https://github.com/larryhastings/co_annotations/

Inada Naoki discovered a crash in that branch, discussed here, including steps to reproduce:

https://github.com/larryhastings/co_annotations/issues/10

valgrind showed me what the problem was.  stackeffect() allocates a "stack" variable, used to store pushed/popped context while iterating over the basic blocks of the function being assembled.  Most of the time, the stack is way bigger than it needs to be--we allocate 4 or 5 entries and it only uses 1 or 2.  But, somehow, in the co_annotations branch, the "stack" was occasionally *way too small*.  As in, it allocated 66 entries (!) but used 150 (!!).

I don't understand exactly how stackeffect works, so I don't know under what circumstances it would go so deep, much less what would cause it to so severely underestimate how many entries it needed.  I *did* make modifications to code generation in compile.c, so it *could* be my bug--but my changes were all much earlier in the process, and AFAIK I never touched any of the code under assemble().

Well, not until I worked around this problem, anyway.  My fix: if "stack" is too small, double the size and realloc().  Certainly it makes the problem go away.  That's checked in to my branch here:

https://github.com/larryhastings/co_annotations/commit/63b415c3607af8ba9263b179fb05bb89ccd2e036

But it doesn't address the underlying bug, whatever it is.

If anybody who understands stackeffect() could take a look and figure it out?  That would be neat-o keen.
History
Date User Action Args
2021-04-19 23:00:10larrysetrecipients: + larry
2021-04-19 23:00:10larrysetmessageid: <1618873210.06.0.38844739847.issue43891@roundup.psfhosted.org>
2021-04-19 23:00:10larrylinkissue43891 messages
2021-04-19 23:00:09larrycreate