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 grahamd
Recipients barry, benjamin.peterson, christian.heimes, grahamd, loewis
Date 2009-07-20.12:42:51
SpamBayes Score 1.5097467e-06
Marked as misclassified No
Message-id <1248093773.05.0.6474262266.issue4200@psf.upfronthosting.co.za>
In-reply-to
Content
This new problem I am seeing looks like it may be linked to where the 
'atexit' module is initialised/imported in a sub interpreter but never 
in the main interpreter. I can avoid the crash by having:

    PyImport_ImportModule("atexit");

    Py_Finalize();

At a guess, this is because:

    module = PyState_FindModule(&atexitmodule);
    if (module == NULL)
        return;

still returns a module for case where imported in a sub interpreter but 
not in main interpreter, but then:

    modstate = GET_ATEXIT_STATE(module);

    if (modstate->ncallbacks == 0)
        return;

returns NULL for modstate for the main interpreter as PyInit_atexit() 
had never been called for the main interpreter.

The fix would appear to be to check modstate for being NULL and return. 
Ie.,

    module = PyState_FindModule(&atexitmodule);
    if (module == NULL)
        return;
    modstate = GET_ATEXIT_STATE(module);

    if (modstate == NULL)
        return;

    if (modstate->ncallbacks == 0)
        return;

Does that make sense to anyone? If it does and I am correct, I'll create 
a new issue for it as original fix seems deficient.
History
Date User Action Args
2009-07-20 12:42:53grahamdsetrecipients: + grahamd, loewis, barry, christian.heimes, benjamin.peterson
2009-07-20 12:42:53grahamdsetmessageid: <1248093773.05.0.6474262266.issue4200@psf.upfronthosting.co.za>
2009-07-20 12:42:51grahamdlinkissue4200 messages
2009-07-20 12:42:51grahamdcreate