Usually this means that you&#39;re not doing an INCREF in a place where you should, and the object is kept alive by something else. Do you know which object it is? That might really help... Possibly deleting the last subinterpreter makes the refcount of that object go to zero. Of course it could also be that you&#39;re doing a DECREF you shouldn&#39;t be doing... But the identity of the object seems key in any case.<br>

<br>--Guido<br><br><div class="gmail_quote">On Mon, Feb 6, 2012 at 6:57 AM, Brett Cannon <span dir="ltr">&lt;<a href="mailto:brett@python.org">brett@python.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

So my grand quest for bootstrapping importlib into CPython is damn close to coming to fruition; I have one nasty bug blocking my way and I can&#39;t figure out what could be causing it. I&#39;m hoping someone here will either know the solution off the top of their head or will have the time to have a quick look to see if they can figure it out as my brain is mush at this point.<div>



<br></div><div>First, the bug tracking all of this is <a href="http://bugs.python.org/issue2377" target="_blank">http://bugs.python.org/issue2377</a> and the repo where I have been doing my work is ssh://<a href="http://hg@hg.python.org/sandbox/bcannon/#bootstrap_importlib" target="_blank">hg@hg.python.org/sandbox/bcannon/#bootstrap_importlib</a> (change as needed if you want an HTTPS checkout). Everything works fine as long as you don&#39;t use sub-interpreters via test_capi (sans some test failures based on some assumptions which can easily be fixed; the bug I&#39;m talking about is the only real showstopper at this point).</div>



<div><br></div><div>Here is the issue: if you run test_capi the code triggers an assertion of ``test_subinterps (__main__.TestPendingCalls) ... Assertion failed: (gc-&gt;gc.gc_refs != 0), function visit_decref, file Modules/gcmodule.c, line 327.``. If you run the test under gdb you will discover that the assertion is related to ref counts when collecting for a generation (basically the ref updating is hitting 0 when it shouldn&#39;t).</div>



<div><br></div><div>Now the odd thing is that this is happening while importing frozen module code (something I didn&#39;t touch) which is calling marshal (something else I didn&#39;t touch) and while it is in the middle of unmarshaling the frozen module code it is triggering the assertion.</div>



<div><br></div><div>Does anyone have any idea what is going on? Am I possibly doing something stupid with refcounts which is only manifesting when using sub-interpreters? All relevant code for bootstrapping is contained in Python/pythonrun.c:import_init() (with a little tweaking in the _io module to delay importing the os module and making import.c always use __import__ instead of using the C code). I&#39;m storing the __import__ function in the PyInterpreterState to keep separate state from the other interpreters (i.e. separate sys modules so as to use the proper sys.modules, etc.). But as I said, this all works in a single interpreter view of the world (the entire test suite doesn&#39;t trigger a nasty error like this).</div>



<div><br></div><div>Thanks for any help people can provide me on this now 5 year quest to get this work finished.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-Brett</div>
</font></span><br>_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-dev" target="_blank">http://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="http://mail.python.org/mailman/options/python-dev/guido%40python.org" target="_blank">http://mail.python.org/mailman/options/python-dev/guido%40python.org</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>--Guido van Rossum (<a href="http://python.org/~guido">python.org/~guido</a>)<br>