Movatterモバイル変換
[0]ホーム
[Python-Dev] need help with frozen module/marshal/gc issue involving sub-interpreters for importlib bootstrapping
Brett Cannonbrett at python.org
Mon Feb 6 15:57:56 CET 2012
So my grand quest for bootstrapping importlib into CPython is damn close tocoming to fruition; I have one nasty bug blocking my way and I can't figureout what could be causing it. I'm hoping someone here will either know thesolution off the top of their head or will have the time to have a quicklook to see if they can figure it out as my brain is mush at this point.First, the bug tracking all of this ishttp://bugs.python.org/issue2377 andthe repo where I have been doing my work isssh://hg at hg.python.org/sandbox/bcannon/#bootstrap_importlib (change as needed ifyou want an HTTPS checkout). Everything works fine as long as you don't usesub-interpreters via test_capi (sans some test failures based on someassumptions which can easily be fixed; the bug I'm talking about is theonly real showstopper at this point).Here is the issue: if you run test_capi the code triggers an assertion of``test_subinterps (__main__.TestPendingCalls) ... Assertion failed:(gc->gc.gc_refs != 0), function visit_decref, file Modules/gcmodule.c, line327.``. If you run the test under gdb you will discover that the assertionis related to ref counts when collecting for a generation (basically theref updating is hitting 0 when it shouldn't).Now the odd thing is that this is happening while importing frozen modulecode (something I didn't touch) which is calling marshal (something else Ididn't touch) and while it is in the middle of unmarshaling the frozenmodule code it is triggering the assertion.Does anyone have any idea what is going on? Am I possibly doing somethingstupid with refcounts which is only manifesting when usingsub-interpreters? All relevant code for bootstrapping is contained inPython/pythonrun.c:import_init() (with a little tweaking in the _io moduleto delay importing the os module and making import.c always use __import__instead of using the C code). I'm storing the __import__ function in thePyInterpreterState to keep separate state from the other interpreters (i.e.separate sys modules so as to use the proper sys.modules, etc.). But as Isaid, this all works in a single interpreter view of the world (the entiretest suite doesn't trigger a nasty error like this).Thanks for any help people can provide me on this now 5 year quest to getthis work finished.-Brett-------------- next part --------------An HTML attachment was scrubbed...URL: <http://mail.python.org/pipermail/python-dev/attachments/20120206/e8a8a824/attachment.html>
More information about the Python-Devmailing list
[8]ページ先頭