[ python-Bugs-1720705 ] thread + import => crashes?

SourceForge.net noreply at sourceforge.net
Wed Jun 20 01:40:50 CEST 2007


Bugs item #1720705, was opened at 2007-05-17 13:08
Message generated for change (Comment added) made by andyshorts
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1720705&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: Python 2.5
Status: Open
Resolution: None
Priority: 6
Private: No
Submitted By: Hirokazu Yamamoto (ocean-city)
Assigned to: Nobody/Anonymous (nobody)
Summary: thread + import => crashes?

Initial Comment:
I got some experience of crash on Tkinter, so I minimized triger code. (I'll attach it as 'bug.py')
Same error happens on released python 2.5.1 binary, trunk built with VC6, and release25-maint built with VC6. (Not every time this error occurs, but frequently)

# Here is error message.

S:\python\tkinter>bug.py
Traceback (most recent call last):
  File "S:\python\tkinter\bug.py", line 13, in <module>
    raise RuntimeError()
RuntimeError
Fatal Python error: PyImport_GetModuleDict: no module dictionary!

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

# Here is stack trace. (Win2000SP4 + VC6)

NTDLL! 77f9193c()
PyImport_GetModuleDict() line 361 + 10 bytes
import_submodule(_object * 0x1e3148b8 __Py_NoneStruct, char * 0x013fe440, char * 0x013fe440) line 2357 + 5 bytes
load_next(_object * 0x1e3148b8 __Py_NoneStruct, _object * 0x1e3148b8 __Py_NoneStruct, char * * 0x013fe554, char * 0x013fe440, int * 0x013fe43c) line 2216 + 17 bytes
import_module_level(char * 0x00000000, _object * 0x008e6620, _object * 0x1e3148b8 __Py_NoneStruct, _object * 0x1e3148b8 __Py_NoneStruct, int -1) line 1997 + 35 bytes
PyImport_ImportModuleLevel(char * 0x009408cc, _object * 0x008e6620, _object * 0x1e3148b8 __Py_NoneStruct, _object * 0x1e3148b8 __Py_NoneStruct, int -1) line 2068 + 25 bytes
builtin___import__(_object * 0x00000000, _object * 0x00b0aaa0, _object * 0x00000000) line 48 + 25 bytes
PyCFunction_Call(_object * 0x008cf478, _object * 0x00b0aaa0, _object * 0x00000000) line 77 + 15 bytes
PyObject_Call(_object * 0x008cf478, _object * 0x00b0aaa0, _object * 0x00000000) line 1860 + 15 bytes
PyEval_CallObjectWithKeywords(_object * 0x008cf478, _object * 0x00b0aaa0, _object * 0x00000000) line 3434
PyEval_EvalFrameEx(_frame * 0x00a5d3e8, int 107) line 2065
fast_function(_object * 0x00000000, _object * * * 0x013fef00, int 1, int 1, int 10152296) line 3651
call_function(_object * * * 0x013fef00, int 0) line 3585 + 16 bytes
PyEval_EvalFrameEx(_frame * 0x00a706b8, int 131) line 2269
PyEval_EvalCodeEx(PyCodeObject * 0x009e80e8, _object * 0x00a706b8, _object * 0x00000002, _object * * 0x00ac86a0, int 2, _object * * 0x00ac86a8, int 0, _object * * 0x00a1ccfc, int 1, _object * 0x00000000) line 2831 + 11 bytes
fast_function(_object * 0x00000001, _object * * * 0x013ff418, int 2, int 2, int 0) line 3663 + 53 bytes
call_function(_object * * * 0x013ff418, int 0) line 3585 + 16 bytes
PyEval_EvalFrameEx(_frame * 0x00ac8528, int 131) line 2269
PyEval_EvalCodeEx(PyCodeObject * 0x009e4c88, _object * 0x00ac8528, _object * 0x00000002, _object * * 0x00a5b590, int 2, _object * * 0x00a5b598, int 0, _object * * 0x00a1cc1c, int 1, _object * 0x00000000) line 2831 + 11 bytes
fast_function(_object * 0x00000001, _object * * * 0x013ff930, int 2, int 2, int 0) line 3663 + 53 bytes
call_function(_object * * * 0x013ff930, int 0) line 3585 + 16 bytes
PyEval_EvalFrameEx(_frame * 0x00a5b440, int 131) line 2269
PyEval_EvalCodeEx(PyCodeObject * 0x009e44a8, _object * 0x00a5b440, _object * 0x00000001, _object * * 0x00a5b224, int 1, _object * * 0x00a5b228, int 0, _object * * 0x00a1e9cc, int 2, _object * 0x00000000) line 2831 + 11 bytes
fast_function(_object * 0x00000002, _object * * * 0x013ffe48, int 1, int 1, int 0) line 3663 + 53 bytes
call_function(_object * * * 0x013ffe48, int 0) line 3585 + 16 bytes
PyEval_EvalFrameEx(_frame * 0x00a5b0e0, int 131) line 2269
PyEval_EvalCodeEx(PyCodeObject * 0x009d5ce8, _object * 0x00a5b0e0, _object * 0x00000000, _object * * 0x008c104c, int 0, _object * * 0x00000000, int 0, _object * * 0x00000000, int 0, _object * 0x00000000) line 2831 + 11 bytes
function_call(_object * 0x00a2b140, _object * 0x008c1038, _object * 0x00000000) line 522 + 64 bytes
PyObject_Call(_object * 0x00a2b140, _object * 0x008c1038, _object * 0x00000000) line 1860 + 15 bytes
PyEval_CallObjectWithKeywords(_object * 0x00a2b140, _object * 0x008c1038, _object * 0x00000000) line 3434
t_bootstrap(void * 0x008c8508) line 425 + 26 bytes
bootstrap(void * 0x0022f8cc) line 179 + 7 bytes
_threadstart(void * 0x009bff78) line 187 + 13 bytes
KERNEL32! 77e5b396()


----------------------------------------------------------------------

Comment By: AndyShorts (andyshorts)
Date: 2007-06-19 23:40

Message:
Logged In: YES 
user_id=1563697
Originator: NO

I have had a look at this using the latest trunk code built using
VisualStudio 2005 on Windows XP SP2.

I modified the source scripts from bug2.zip so that the code was wrapped
in a function and added the same code as a function to main.py; I did this
so as to see if the difference in calling method would affect it at all,
i.e. if by removing the import of sub.py it would make the issue any better
or worse.

Running it in the debugger and modifying the debug output from the engine
to include Win32 thread identifiers seems to suggest that the main thread
is exiting and cleaning up the Python system modules and then the Win32
system is closing the other Python threads which are then trying to access
the global Python modules and they can't find them and they exit. [Though
as a /total/ newbie to Python I am only about 40-50% confident of this] And
as to be expected the error does not happen all the time - I can run the
same script and maybe get the error as listed maybe about 60-70% of the
time.

Interestingly in main.c there is a call to a function called
"WaitForThreadShutdown" - but sadly it only looks to see if the Python
threading module has been imported. I think extending this function to
include the Python thread module might be the way to go - but I really
don't know and I certainly haven't got to grips with the Python source yet.

----------------------------------------------------------------------

Comment By: Hirokazu Yamamoto (ocean-city)
Date: 2007-05-17 14:49

Message:
Logged In: YES 
user_id=1200846
Originator: YES

Sorry, Tkinter and urllib is not source of problem. I changed summary to
"thread + import => crashes?".

# I'll attach reproducable script as "bug.zip". please run main.py

Probabry "import" in another thread causes crash, but I'll investigate
more.
File Added: bug.zip

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1720705&group_id=5470


More information about the Python-bugs-list mailing list