New submission from Ronald Oussoren:

Py_Finalize cleans up the thread state by first calling _PyGILState_Fini 
and then calling PyInterpreterState_Clear. The latter can cause user 
code to run, which could use the GILState API and this then causes a 
crash.

The attached file 'threads.py' causes a crash on OSX leopard because of 
this issue. The script causes an exception to be set that has an 
attribute that uses the GILState API in its dealloc slot.

----------
components: Interpreter Core
files: threads.py
messages: 57225
nosy: ronaldoussoren
priority: normal
severity: normal
status: open
title: Interpreter cleanup: order of _PyGILState_Fini and 
PyInterpreterState_Clear
type: crash
versions: Python 2.5
Added file: http://bugs.python.org/file8710/threads.py

__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1402>
__________________________________
from Foundation import *
import threading


class MyObject (NSObject):
    def myMethod_(self, dummy):
        print dummy
        raise RuntimeError("hello")

obj = MyObject.new()


class MyThread(threading.Thread):

    def run(self):
        while True:
            pool = NSAutoreleasePool.alloc().init()

            print "Doit!"
            obj.performSelectorOnMainThread_withObject_waitUntilDone_(
                    'myMethod:', [], True)
            print "Result is in"


            del pool


t = MyThread()
t.setDaemon(1)
t.start()

loop = NSRunLoop.currentRunLoop()
try:
    loop.run()
except:
    print "Exception!"

print "Ready!"
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to