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.

Title: Bug in _PyUnicode_ClearStaticStrings() method of unicodeobject.c
Type: crash Stage: resolved
Components: None Versions: Python 3.3
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, brett.cannon, georg.brandl, goodger, larry, loewis, prashantkurnawal, python-dev
Priority: normal Keywords:

Created on 2013-01-09 11:31 by prashantkurnawal, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
unicodeobject.c prashantkurnawal, 2013-01-09 11:31
Messages (4)
msg179432 - (view) Author: Prashant Kurnawal (prashantkurnawal) Date: 2013-01-09 11:31
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) {
           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;
        i->object = NULL;
        i->next = NULL;
    static_strings->object = NULL;
    static_strings = NULL;
Is this a bug or it is done so intentionally..?
msg179433 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2013-01-09 11:36
It's a bug; thanks for pointing this out. I always suspected that there was something wrong, but never found the time to look into it.
msg179443 - (view) Author: Prashant Kurnawal (prashantkurnawal) Date: 2013-01-09 14:12
When are you planning to submit a fix for it..? This bug will be fixed in python3.3 and a new version of python3.3 will be released..? Or it will be fixed in python3.4..?
msg179460 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-01-09 15:52
New changeset 3e18ccaa537e by Benjamin Peterson in branch '3.3':
correct static string clearing loop (closes #16906)

New changeset 0c04ed40eeaf by Benjamin Peterson in branch 'default':
merge 3.3 (#16906)
Date User Action Args
2022-04-11 14:57:40adminsetgithub: 61110
2013-01-09 15:52:36python-devsetstatus: open -> closed
resolution: fixed
messages: + msg179460

stage: resolved
2013-01-09 14:12:45prashantkurnawalsetmessages: + msg179443
2013-01-09 11:36:58loewissetnosy: + loewis
messages: + msg179433
2013-01-09 11:31:37prashantkurnawalcreate