On Oct 1, 2008, at 11:19 AM, Lisandro Dalcin wrote: > BTW, this patch fix the issue by not initializing cdef'ed module > globals to None. But this is not the safest approach (I can imagine > some nasty ways to originate segfaults). Perhaps we should try to fix > the isue in FinalOptimizePhase.visit_SingleAssignmentNode
I agree that this should be fixed (I remember debugging a nasty bug where the refcount of the integer 0 wrapped around, ugh..). However, FinalOptimizePhase is the right place to do it. > > On Wed, Oct 1, 2008 at 3:13 PM, Lisandro Dalcin <[EMAIL PROTECTED]> > wrote: >> Consider the following code inside a one-line pyx file: >> >> cdef object someint = 7 >> >> Then Cython generates the following inside the module init function: >> >> /*--- Global init code ---*/ >> __pyx_v_9refleaks2_someint = Py_None; Py_INCREF(Py_None); >> >> /* "/u/dalcinl/Devel/Cython/sandbox/refleaks2.pyx":1 >> * cdef object someint = 7 # <<<<<<<<<<<<<< >> * >> */ >> Py_INCREF(__pyx_int_7); >> __pyx_v_9refleaks2_someint = __pyx_int_7; >> >> >> Clearly, Py_None references are being leaked. All this is because of >> bad interaction between this two methods: >> >> * ModuleNode.generate_global_init_code(...) (in ModuleNode.py) >> * FinalOptimizePhase.visit_SingleAssignmentNode(...) (in Optimize.py) >> >> >> >> -- >> Lisandro Dalcín >> --------------- >> Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC) >> Instituto de Desarrollo Tecnológico para la Industria Química (INTEC) >> Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET) >> PTLC - Güemes 3450, (3000) Santa Fe, Argentina >> Tel/Fax: +54-(0)342-451.1594 >> > > > > -- > Lisandro Dalcín > --------------- > Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC) > Instituto de Desarrollo Tecnológico para la Industria Química (INTEC) > Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET) > PTLC - Güemes 3450, (3000) Santa Fe, Argentina > Tel/Fax: +54-(0) > 342-451.1594<fixinitnoneleaks.diff>___________________________________ > ____________ > Cython-dev mailing list > [email protected] > http://codespeak.net/mailman/listinfo/cython-dev _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
