[Python-bugs-list] [Bug #131189] Crash when Python Re-Initialized with Daemon Threads
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 09 Feb 2001 15:33:24 -0800
Bug #131189, was updated on 2001-Feb-05 15:04
Here is a current snapshot of the bug.
Project: Python
Category: Python Interpreter Core
Status: Open
Resolution: None
Bug Group: None
Priority: 5
Submitted by: jpettit
Assigned to : gvanrossum
Summary: Crash when Python Re-Initialized with Daemon Threads
Details: When "threadCrash.c" is built and run, it will fail with a
segmentation fault. It appears Py_Finalize is not properly cleaning up the
threads. Under the "Bugs and caveats" section of Py_Finalize in the
Python/C API Reference Manual (api\initialization.html), it mentions
various problems, but doesn't mention this one.
I've tested this with Python 2.0 on Win2K, Linux, and OpenBSD.
--------- threadCrash.c ---------
#include "Python.h"
#define THREAD_FILE "simpleThread.py"
main(int argc, char **argv)
{
FILE *threadScript;
Py_SetProgramName(argv[0]);
while (1)
{
Py_Initialize();
threadScript = fopen(THREAD_FILE, "r");
PyRun_SimpleFile(threadScript, THREAD_FILE);
fclose(threadScript);
// Destroy our interpreter for a clean restart
Py_Finalize();
}
}
--------- simpleThread.py ---------
import threading
import time
class simple(threading.Thread):
def __init__(self, idNum):
threading.Thread.__init__(self)
self.idNum = idNum
def run(self):
while 1:
print self.idNum
time.sleep(1)
for i in range(5):
a = simple(i)
a.start()
--------- end ---------
Follow-Ups:
Date: 2001-Feb-09 15:33
By: tim_one
Comment:
Assigned to Guido.
jpettit, the whitespace isn't actually destroyed, that's simply what
browsers *do* with runs of whitespace (i.e., they collapse them). The
leading whitespace is still present in the database, and you'll see it e.g.
in the email SourceForge generates. We have a request outstanding with
SourceForge to do a better job of this on the web pages (e.g., generating
instead of literal spaces).
-------------------------------------------------------
Date: 2001-Feb-05 15:08
By: jpettit
Comment:
Sorry, the subject line is misleading. I had originally thought this had
something to do with daemonic threads, but it seems to be a general thread
issue. Also, it appears that SourceForge likes to eat proceeding white
space, which has munged my Python code. It should be fairly
straight-forward, though, to determine what I meant. Is there a preferred
way to submit Python code to SourceForge?
-------------------------------------------------------
For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=131189&group_id=5470