[ python-Bugs-1193099 ] Embedded python thread crashes
SourceForge.net
noreply at sourceforge.net
Wed Oct 5 20:39:25 CEST 2005
Bugs item #1193099, was opened at 2005-04-30 12:03
Message generated for change (Comment added) made by ugodiggi
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1193099&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: None
Status: Open
Resolution: None
Priority: 5
Submitted By: ugodiggi (ugodiggi)
Assigned to: Nobody/Anonymous (nobody)
Summary: Embedded python thread crashes
Initial Comment:
The following code crashes about 1/3 of the times.
My platform is Python 2.4.1 on WXP (I tried the release
version from the msi and the debug version built by me).
I can reproduce the same behavior on another wxp
system, under python 2.4.
The crash happens (in the python thread) while the main
thread is in Py_Finalize.
I traced the crash to _Py_ForgetReference(op) in
object.c at line 1847, where I have op->_ob_prev == NULL.
The open file seems to be the issue, since if I remove
all the references to the file I cannot get the program
to crash.
Cheers and ciao
Ugo
////////////////////////// TestPyThreads.cpp
//////////////////////////
#include <windows.h> // Sleep
#include "Python.h"
int main()
{
PyEval_InitThreads();
Py_Initialize();
PyGILState_STATE main_restore_state =
PyGILState_UNLOCKED;
PyGILState_Release(main_restore_state);
// start the thread
{
PyGILState_STATE state =
PyGILState_Ensure();
int trash = PyRun_SimpleString(
"import thread\n"
"import time\n"
"def foo():\n"
" f =
open('pippo.out', 'w', 0)\n"
" i = 0;\n"
" while 1:\n"
" f.write('%d\n'%i)\n"
" time.sleep(0.01)\n"
" i += 1\n"
"t =
thread.start_new_thread(foo, ())\n"
);
PyGILState_Release(state);
}
// wait 300 ms
Sleep(300);
PyGILState_Ensure();
Py_Finalize();
return 0;
}
----------------------------------------------------------------------
>Comment By: ugodiggi (ugodiggi)
Date: 2005-10-05 11:39
Message:
Logged In: YES
user_id=1269908
I would guess that the problem is going to be windows
specific?
I tested similar problem on both the debug and release build,
and I did try to get some comment on comp.lang.python
i.e.
http://mail.python.org/pipermail/python-list/2005-
April/278404.html
my comment on the debugging was:
> The crash happens while the main thread is in Py_Finalize.
> I traced the crash to _Py_ForgetReference(op) in object.c
at line 1847,
> where I have op->_ob_prev == NULL.
I did not look at the python code long enough to follow it.
I will try to reproduce tonight and send out the stack - for
whatever reason I'm not finding it any longer.
----------------------------------------------------------------------
Comment By: Neal Norwitz (nnorwitz)
Date: 2005-10-03 22:37
Message:
Logged In: YES
user_id=33168
I can't reproduce on gentoo linux (amd64) with a debug
build. I played with different values for sleep. BTW, it
would be better if you attached the code as a file, since
formatting is lost.
Can you try to debug this problem?
Can you attach info from the debugger?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1193099&group_id=5470
More information about the Python-bugs-list
mailing list