-
Notifications
You must be signed in to change notification settings - Fork 61
Crash after unpickling hard switched tasklet #61
Comments
Original comment by Anselm Kruis (Bitbucket: akruis, GitHub: akruis): I just added pull request #11 to fix the second bug. And I discovered '\r\n' line endings in the new test script Stackless/test/unpickle_crash_issue61.py added by pull request #10, commit fb46ecf79d49. We must not merge this pull request. I'll recreate it. |
Original comment by Anselm Kruis (Bitbucket: akruis, GitHub: akruis): OK, I merged the pull requests into 2.7-slp, grafted the changes into 3.2-slp and merged them into 3.3-slp, 3.4-slp and default-slp. @ctismer I don't have a 2.8-slp sandbox right now, so please could you merge the changes into 2.8-slp. |
Original comment by Anselm Kruis (Bitbucket: akruis, GitHub: akruis): Should be fairly simple:
See https://docs.python.org/devguide/faq.html#id48 for further information. |
Original comment by Christian Tismer (Bitbucket: ctismer, GitHub: ctismer): Ah, thanks! I tried a merge using SourceTree, but reverted that. What I did not understand in the first place was what to do about the changes of Actually, I think it is time to publish 2.8 now, if we still want to do that. Is it true that the repo is already gone public, or was that by chance in the sprint? |
Originally reported by: Anselm Kruis (Bitbucket: akruis, GitHub: akruis)
Hi,
a few weeks ago I observed crashes during the development of pyheapdump. Now I had some time to track them down and to write a small example.
The attached script first pickles a single frame and unpickles the frame. Then it accesses frame.f_locals. Python crashes in function map_to_dict() from frameobject.c. This function is invoked from PyFrame_FastToLocals().
Obviously we have two bugs:
Upon unpickling python fails to set up frame->f_localsplus correctly (== as expected by PyFrame_FastToLocals) in function frame_setstate from prickelpit.c. The localsplus array must start with frame->f_code->co_nlocals local variables, followed by len(frame->f_code->co_cellvars) + len(frame->f_code->co_freevars) cell objects.
Upon pickling python creates an inconsistent object state for the frame in function frameobject_reduce from prickelpit.c. If the frame has no stacktop, python omits the localsplus array from the pickle. This would be correct, if the only valid use case for pickling frames was pickling, unpickling and resuming of tasklets. But is is also possible to pickle/unpickle a tasklet with the sole intent to inspect it using a debugger.
Plan
I'll add test cases for the two bugs and prepare pull requests with fixes.
Here is the code:
f_locals_crash.py.zip
The text was updated successfully, but these errors were encountered: