New submission from Thomas Mortensson:
Unsure how to re-produce. Have a CoreDump file with the below backtrace. Our
module is socc, we were running a Twisted application and Python core dumped
giving us the following backtrace.
Looks like we failed to spawn a process wsing os.fork() due to a double free in
PyThread_ReInitTLS.
System Details:
CentOS 6.5
Kernel - 2.6.32-696.el6.x86_64
Python 2.7.13 (default, Feb 6 2017, 15:27:35)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-10)] on linux2
GDB - GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-64.el6
File "/usr/local/lib/python2.7/site-packages/socc/cloudTransport/transport.py",
line 128, in executeProcessInThread
line +128
ret = reactor.spawnProcess(execProtocol, args[0], args, env=os.environ,
childFDs={0: "w", 1: "r", 2: "r"})
Python backtrace:
(gdb) py-bt
Traceback (most recent call first):
File "/usr/local/lib/python2.7/site-packages/twisted/internet/process.py",
line 382, in _fork
self.pid = os.fork()
File "/usr/local/lib/python2.7/site-packages/twisted/internet/process.py",
line 677, in __init__
self._fork(path, uid, gid, executable, args, environment, fdmap=fdmap)
File "/usr/local/lib/python2.7/site-packages/twisted/internet/posixbase.py",
line 345, in spawnProcess
processProtocol, uid, gid, childFDs)
File
"/usr/local/lib/python2.7/site-packages/socc/cloudTransport/transport.py", line
128, in executeProcessInThread
File "/usr/local/lib/python2.7/site-packages/twisted/python/context.py", line
81, in callWithContext
return func(*args,**kw)
File "/usr/local/lib/python2.7/site-packages/twisted/python/context.py", line
118, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/usr/local/lib/python2.7/site-packages/twisted/python/threadpool.py",
line 196, in _worker
result = context.call(ctx, function, *args, **kwargs)
File "/usr/local/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/local/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/local/lib/python2.7/threading.py", line 774, in __bootstrap
self.__bootstrap_inner()
/* Forget everything not associated with the current thread id.
* This function is called from PyOS_AfterFork(). It is necessary
* because other thread ids which were in use at the time of the fork
* may be reused for new threads created in the forked process.
*/
void
PyThread_ReInitTLS(void)
{
long id = PyThread_get_thread_ident();
struct key *p, **q;
if (!keymutex)
return;
/* As with interpreter_lock in PyEval_ReInitThreads()
we just create a new lock without freeing the old one */
keymutex = PyThread_allocate_lock();
/* Delete all keys which do not match the current thread id */
q = &keyhead;
while ((p = *q) != NULL) {
if (p->id != id) {
*q = p->next;
free((void *)p); <-FAILED HERE
/* NB This does *not* free p->value! */
}
else
q = &p->next;
}
}
Installed
python27-Logbook-debuginfo-0.9.1-1.el6_7.x86_64.rpm
python27-PyYAML-debuginfo-3.12-1.x86_64.rpm
python27-Twisted-debuginfo-14.0.0-1.x86_64.rpm
python27-cffi-debuginfo-1.9.1-1.el6_7.x86_64.rpm
python27-cryptography-debuginfo-1.7.2-1.el6_7.x86_64.rpm
python27-debuginfo-2.7.13-2.el6_7.x86_64.rpm
python27-psutil-debuginfo-5.1.3-1.x86_64.rpm
python27-simplejson-debuginfo-3.10.0-1.el6_7.el6_7.x86_64.rpm
python27-zope-interface-debuginfo-4.3.3-1.x86_64.rpm
Backtrace is:
#0 0x76db0625 in raise () from /lib64/libc.so.6
#1 0x76db1e05 in abort () from /lib64/libc.so.6
#2 0x76dee537 in __libc_message () from /lib64/libc.so.6
#3 0x76df3f4e in malloc_printerr () from /lib64/libc.so.6
#4 0x76df6cad in _int_free () from /lib64/libc.so.6
#5 0x77b082a9 in PyThread_ReInitTLS () at Python/thread.c:413
#6 0x77b0fbb4 in PyOS_AfterFork () at Modules/signalmodule.c:1004
#7 0x77b12cf6 in posix_fork (self=, noargs=) at Modules/posixmodule.c:3875
#8 0x77ac8460 in call_function (oparg=,
pp_stack=0x7fffdc043fb0) at Python/ceval.c:4336
#9 PyEval_EvalFrameEx (f=f@entry=0x36bb930, throwflag=throwflag@entry=0) at
Python/ceval.c:2989
#10 0x77ac9d0d in PyEval_EvalCodeEx (co=,
globals=, locals=locals@entry=0x0, args=,
argcount=argcount@entry=7, kws=kws@entry=0x36b54d0, kwcount=1, defs=0x0,
defcount=0, closure=0x0)
at Python/ceval.c:3584
#11 0x77ac8800 in fast_function (nk=, na=7, n=, pp_stack=0x7fffdc0441f0, func=) at Python/ceval.c:4447
#12 call_function (oparg=, pp_stack=0x7fffdc0441f0) at
Python/ceval.c:4372
#13 PyEval_EvalFrameEx (f=f@entry=0x36b5270, throwflag=throwflag@entry=0) at
Python/ceval.c:2