[ python-Bugs-1429585 ] segfault in FreeBSD

SourceForge.net noreply at sourceforge.net
Sun Feb 12 22:09:23 CET 2006


Bugs item #1429585, was opened at 2006-02-11 00:16
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1429585&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: Extension Modules
Group: Python 2.4
Status: Open
>Resolution: Works For Me
Priority: 5
Submitted By: aix-d (aix-d)
>Assigned to: Neal Norwitz (nnorwitz)
Summary: segfault in FreeBSD

Initial Comment:
Dear developers,

My program has many TCP connections (~30 per second),
MySQL connections (~100 per second) and threads (~280).
It works long time and receives this segmentation fault:

exited on signal 11 (core dumped)

=========== GDB OUTPUT
=================================================
Program received signal SIGSEGV, Segmentation fault.
0x283199e8 in ?? () from
/usr/local/lib/python2.4/lib-dynload/_socket.so
(gdb) backtrace
#0  0x283199e8 in ?? () from
/usr/local/lib/python2.4/lib-dynload/_socket.so
#1  0x2831b3d5 in internal_connect ()
   from /usr/local/lib/python2.4/lib-dynload/_socket.so
#2  0x2831b440 in sock_connect ()
   from /usr/local/lib/python2.4/lib-dynload/_socket.so
#3  0x0805a828 in PyObject_Call ()
#4  0x080a01dd in PyEval_EvalFrame ()
#5  0x080a294f in PyEval_EvalCodeEx ()
#6  0x080a138b in PyEval_EvalFrame ()
#7  0x080a212d in PyEval_EvalFrame ()
#8  0x080a212d in PyEval_EvalFrame ()
#9  0x080a212d in PyEval_EvalFrame ()
#10 0x080a212d in PyEval_EvalFrame ()
#11 0x080a212d in PyEval_EvalFrame ()
#12 0x080a294f in PyEval_EvalCodeEx ()
#13 0x080a138b in PyEval_EvalFrame ()
#14 0x080a212d in PyEval_EvalFrame ()
#15 0x080a294f in PyEval_EvalCodeEx ()
#16 0x080da027 in PyFunction_SetClosure ()
#17 0x0805a828 in PyObject_Call ()
#18 0x080a01dd in PyEval_EvalFrame ()
#19 0x080a294f in PyEval_EvalCodeEx ()
#20 0x080a138b in PyEval_EvalFrame ()
#21 0x080a294f in PyEval_EvalCodeEx ()
#22 0x080a138b in PyEval_EvalFrame ()
#23 0x080a294f in PyEval_EvalCodeEx ()
#24 0x080a138b in PyEval_EvalFrame ()
#25 0x080a294f in PyEval_EvalCodeEx ()
#26 0x080a138b in PyEval_EvalFrame ()
#27 0x080a294f in PyEval_EvalCodeEx ()
#28 0x080a138b in PyEval_EvalFrame ()
#29 0x080a294f in PyEval_EvalCodeEx ()
#30 0x080a138b in PyEval_EvalFrame ()
#31 0x080a212d in PyEval_EvalFrame ()
#32 0x080a294f in PyEval_EvalCodeEx ()
#33 0x080da027 in PyFunction_SetClosure ()
#34 0x0805a828 in PyObject_Call ()
#35 0x080601e9 in PyMethod_New ()
#36 0x0805a828 in PyObject_Call ()
#37 0x0809cd31 in PyEval_CallObjectWithKeywords ()
#38 0x080c21a5 in _PyObject_GC_Del ()
#39 0x2821e0cc in pthread_create () from
/usr/lib/libpthread.so.2
#40 0x282db757 in _ctx_start () from /lib/libc.so.6
(gdb)
==== END OF GDB OUTPUT
=================================================

Imported modules: socket, atexit, time, pickle, os,
random, traceback, MySQLdb, re, urllib, urllib2, threading

Python version: 2.4.2

Operating system: FreeBSD 6.0-STABLE

Can you help with debugging?

Best regards, Alexander.

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

>Comment By: Neal Norwitz (nnorwitz)
Date: 2006-02-12 13:09

Message:
Logged In: YES 
user_id=33168

I get exceptions when running normally. I had to do ulimit
-n 2000 to be able to run without exception.

I can confirm that with an unpatched 2.4.2, python crashed.
 With the 2.4.2+ patch, no crash.  On SVN head (2.5), I
didn't get a crash, but got a thread exception.  I think
this bug may be fixed.  To get the new features, you need to
update at least these files:

http://svn.python.org/projects/python/branches/release24-maint/Modules/socketmodule.c
http://svn.python.org/projects/python/branches/release24-maint/Modules/_ssl.c
http://svn.python.org/projects/python/branches/release24-maint/PC/pyconfig.h

Please verify if this is fixed for you.

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

Comment By: Neal Norwitz (nnorwitz)
Date: 2006-02-12 12:54

Message:
Logged In: YES 
user_id=33168

Can you "print *s" ?  My guess is that s->sock_fd >
FD_SETSIZE on your box.  I will try your test code with the
current versions and see if they still fail.

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

Comment By: Uyamba (uyamba)
Date: 2006-02-12 09:48

Message:
Logged In: YES 
user_id=1450360

This is detailed backtrace (from python compiled with 
CFLAGS+="-g"):
======================================
#0  0xa8348959 in ?? ()
#1  0x08ebb800 in ?? ()
#2  0x00000001 in ?? ()
#3  0x77881688 in ?? ()
#4  0x28348947 in internal_connect (s=0x8ebb800, 
addr=0x8ebb818, addrlen=16,
    timeoutp=0x778816b4)
    at /usr/ports/lang/python/work/Python-2.4.2/Modules/
socketmodule.c:1740
#5  0x28348a00 in sock_connect (s=0x8ebb800, 
addro=0x8ebd72c)
    at /usr/ports/lang/python/work/Python-2.4.2/Modules/
socketmodule.c:1771
======================================

This is the /usr/ports/lang/python/work/Python-2.4.2/
Modules/socketmodule.c:
======================================
        if (s->sock_timeout > 0.0) {
1740:           if (res < 0 && errno == EINPROGRESS) {
                        timeout = internal_select(s, 1);
                        res = connect(s->sock_fd, addr, 
addrlen);
                        if (res < 0 && errno == EISCONN)
                                res = 0;
                }
        }
======================================

No ideas :-(

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

Comment By: Uyamba (uyamba)
Date: 2006-02-12 08:47

Message:
Logged In: YES 
user_id=1450360

This is test program that generates fault:
----------------------------
#!/usr/local/bin/python

import socket, time
from threading import Thread

class cthread(Thread):
        def __init__ (self):
                Thread.__init__(self)

        def run(self):
                socket.setdefaulttimeout(5)
                res = socket.getaddrinfo('19.54.123.2', 33, 
0, socket.SOCK_STREAM)[0]
                sock = socket.socket(res[0], res[1], res[2])
                try:
                        sock.connect(res[4])
                except: pass

def main():
        for i in range(1900):
                print "starting " + str(i)
                ct = cthread()
                ct.start()

if __name__ == '__main__':
        main()

----------------------------
IP 19.54.123.2 is random. Results are various for some IPs 
and hostnames.


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

Comment By: Neal Norwitz (nnorwitz)
Date: 2006-02-11 22:54

Message:
Logged In: YES 
user_id=33168

Can you build python from source?  You can try checking out
the current 2.4 SVN.  This problem may have been fixed
recently.  I'm guessing that the socket descriptor value is
larger than FD_SETSIZE (probably 1k or 4k).  You also may
want to build python with debugging.

If that doesn't solve your problem, you will need to provide
more information about how to reproduce your problem.

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

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


More information about the Python-bugs-list mailing list