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 prashantkurnawal
Recipients benjamin.peterson, brett.cannon, georg.brandl, goodger, larry, prashantkurnawal, python-dev
Date 2013-01-09.11:31:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1357731097.9.0.701098252698.issue16906@psf.upfronthosting.co.za>
In-reply-to
Content
I have embedded python3.3 in my application.
I got a crash when I ran a python script containing sample TK window creation code in it.
 
On interpreter shutdown, all strings are released (through _PyUnicode_ClearStaticStrings). (I Found this description in one of the comments of object.h header file)
 
When I tried to debug python source, I found a defect in _PyUnicode_ClearStaticStrings() method.
 
Existing function definition in python3.3 source (unicodeobject.c) is as follows

void _PyUnicode_ClearStaticStrings()
{
     _Py_Identifier *i;
      for (i = static_strings; i; i = i->next) {
           Py_DECREF(i->object);
           i->object = NULL;
           i->next = NULL;
      }
}
 
Here, for loop will not free all the static strings. It will free only the first static string in the list.
This loop needs to be corrected.
 
I corrected the loop in following way and its working fine for me.
 
void _PyUnicode_ClearStaticStrings()
{
    _Py_Identifier *i;
    while(static_strings->next != NULL)
    {
        i = static_strings;
        static_strings = static_strings->next;
        Py_DECREF(i->object);
        i->object = NULL;
        i->next = NULL;
    }
   
    Py_DECREF(static_strings->object);
    static_strings->object = NULL;
    static_strings = NULL;
}
 
Is this a bug or it is done so intentionally..?
History
Date User Action Args
2013-01-09 11:31:40prashantkurnawalsetrecipients: + prashantkurnawal, brett.cannon, georg.brandl, goodger, larry, benjamin.peterson, python-dev
2013-01-09 11:31:37prashantkurnawalsetmessageid: <1357731097.9.0.701098252698.issue16906@psf.upfronthosting.co.za>
2013-01-09 11:31:37prashantkurnawallinkissue16906 messages
2013-01-09 11:31:37prashantkurnawalcreate