[issue1856] shutdown (exit) can hang or segfault with daemon threads running

Gregory P. Smith report at bugs.python.org
Thu Jan 17 03:01:18 CET 2008


New submission from Gregory P. Smith:

This probably applies to 3.0 as well but i have not tested it there.

Here are some sample failures:

=========== A ==============
Exception in thread Thread-0000000001 (most likely raised during
interpreter shutdown):Exception in thread Thread-0000000003 (most likely
raised during interpreter shutdown):

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xe4cf1bb0 (LWP 22281)]
0x080c0824 in PyEval_EvalFrameEx (f=0x820d59c, throwflag=0)
    at Python/ceval.c:2633
2633            if (tstate->frame->f_exc_type != NULL)
============================



=========== B ==============
Exception in thread Thread-0000000001 (most likely raised during
interpreter shutdown):
Traceback (most recent call last):
  File "/home/gps/oss/python/trunk/Lib/threading.py", line 486, in
__bootstrap_inner
  File "thread_exit.py", line 24, in run
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'add'

Program received signal SIGINT, Interrupt.
[Switching to Thread 0xf7fe08e0 (LWP 21703)]
0xffffe410 in __kernel_vsyscall ()
(gdb) bt
#0  0xffffe410 in __kernel_vsyscall ()
#1  0x4dac1af0 in sem_wait at GLIBC_2.0 () from
/lib/tls/i686/cmov/libpthread.so.0
#2  0xf7fe08c0 in ?? ()
#3  0x080ec9d5 in PyThread_acquire_lock (lock=0x0, waitflag=1)
    at Python/thread_pthread.h:349
#4  0x080be6d5 in PyEval_RestoreThread (tstate=0x8168050) at
Python/ceval.c:314
#5  0x0806caf5 in file_dealloc (f=0xf7f29d58) at Objects/fileobject.c:396
#6  0x0810be36 in frame_dealloc (f=0x8201f04) at Objects/frameobject.c:416
#7  0x080e28d2 in PyThreadState_Clear (tstate=0x8184068)
    at Python/pystate.c:217
#8  0x080e2994 in PyInterpreterState_Clear (interp=0x8168008)
    at Python/pystate.c:105
#9  0x080e473b in Py_Finalize () at Python/pythonrun.c:444
#10 0x080e428e in handle_system_exit () at Python/pythonrun.c:1641
#11 0x080e447a in PyErr_PrintEx (set_sys_last_vars=1)
    at Python/pythonrun.c:1087
#12 0x080e510d in PyRun_SimpleFileExFlags (fp=0x817bd98,
    filename=0xffffd73c "thread_exit.py", closeit=1, flags=0xffffd518)
    at Python/pythonrun.c:996
#13 0x0805753b in Py_Main (argc=1, argv=0xffffd5b4) at Modules/main.c:574
#14 0x4d95cea2 in __libc_start_main () from /lib/tls/i686/cmov/libc.so.6
#15 0x080566c1 in _start () at ../sysdeps/i386/elf/start.S:119
(gdb) bt
#0  0x080c0824 in PyEval_EvalFrameEx (f=0x820d59c, throwflag=0)
    at Python/ceval.c:2633
#1  0x080c451c in PyEval_EvalFrameEx (f=0x820d40c, throwflag=0)
    at Python/ceval.c:3690
#2  0x080c451c in PyEval_EvalFrameEx (f=0x820d13c, throwflag=0)
    at Python/ceval.c:3690
#3  0x080c5fd4 in PyEval_EvalCodeEx (co=0xf7f22d58, globals=0xf7f962d4,
    locals=0x0, args=0xf7f46e18, argcount=1, kws=0x0, kwcount=0, defs=0x0,
    defcount=0, closure=0x0) at Python/ceval.c:2876
#4  0x0810d4d6 in function_call (func=0xf7f41454, arg=0xf7f46e0c, kw=0x0)
    at Objects/funcobject.c:524
#5  0x0805b0b4 in PyObject_Call (func=0xf7f41454, arg=0x0, kw=0x0)
    at Objects/abstract.c:1872
#6  0x08061008 in instancemethod_call (func=0xf7f41454, arg=0xf7f46e0c,
kw=0x0)
    at Objects/classobject.c:2509
#7  0x0805b0b4 in PyObject_Call (func=0xf7f3fdec, arg=0x0, kw=0x0)
    at Objects/abstract.c:1872
#8  0x080be8f9 in PyEval_CallObjectWithKeywords (func=0x0, arg=0xf7fa002c,
    kw=0x0) at Python/ceval.c:3473
#9  0x080efb4d in t_bootstrap (boot_raw=0x820c910)
    at ./Modules/threadmodule.c:422
#10 0x4dabd341 in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
#11 0x4da114ee in clone () from /lib/tls/i686/cmov/libc.so.6
============================

And as with all problems of this sort... sometimes the program exits
normally without any problems.

I ran python trunk:60012 under gdb above.  But these problems occur on
older versions such as 2.4.

----------
components: Interpreter Core
files: thread_exit.py
messages: 60014
nosy: gregory.p.smith
severity: normal
status: open
title: shutdown (exit) can hang or segfault with daemon threads running
type: crash
versions: Python 2.4, Python 2.5, Python 2.6
Added file: http://bugs.python.org/file9188/thread_exit.py

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1856>
__________________________________


More information about the Python-bugs-list mailing list