#109 Connection errors & their side effects

MySQLdb-1.1
closed
Andy Dustman
MySQLdb (285)
5
2012-09-19
2004-10-17
Skip Montanaro
No

I just installed Python 2.4b1 and mysql-Python 1.0.0 on my
MacOSX system. In a session with PYTHONSTARTUP unset
and started with "-S", I then imported MySQLdb and
attempted a connect while the server was unavailable. I
got:

Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/Users/skip/local/lib/python2.4/site-packages/
MySQLdb/init.py", line 64, in Connect
return apply(Connection, args, kwargs)
SystemError: ../Python/traceback.c:104: bad argument to
internal function

I then ran it without -S but still with PYTHONSTARTUP unset
and no server running and got:

Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/Users/skip/local/lib/python2.4/site-packages/
MySQLdb/init.py", line 64, in Connect
return apply(Connection, args, kwargs)
File "/Users/skip/local/lib/python2.4/site-packages/
MySQLdb/connections.py", line 116, in init
self._make_connection(args, kwargs2)
File "/Users/skip/local/lib/python2.4/site-packages/
MySQLdb/connections.py", line 41, in _make_connection
apply(super(ConnectionBase, self).init, args, kwargs)
_mysql_exceptions.OperationalError: (2002, "Can't connect
to local MySQL server through socket '/tmp/mysql.sock'
(2)")

More troubling, upon exit I got a BAD_ACCESS fault in
Python's cyclic GC with this backtrace:

Program received signal EXC_BAD_ACCESS, Could not
access memory.
visit_decref (op=0x0, data=0x0) at ../Modules/
gcmodule.c:244
244 if (PyObject_IS_GC(op)) {
(gdb) bt

0 visit_decref (op=0x0, data=0x0) at ../Modules/

gcmodule.c:244

1 0x0005d1e4 in dict_traverse (op=0x46dc00,

visit=0x989d0 <visit_decref>, arg=0x0) at ../Objects/
dictobject.c:1708

2 0x00097e8c in collect (generation=1014956) at ../

Modules/gcmodule.c:269

3 0x00097854 in PyGC_Collect () at ../Modules/

gcmodule.c:1127

4 0x0000b4b8 in Py_Finalize () at ../Python/

pythonrun.c:349

5 0x00006310 in Py_Main (argc=1014956, argv=0x46dbf0)

at ../Modules/main.c:504

6 0x00001c48 in _start (argc=1014956, argv=0x46dbf0,

envp=0xf8550) at /SourceCache/Csu/Csu-45/crt.c:267

7 0x00001ac8 in start ()

My guess there is that something isn't properly cleaned up
after an error during a connection attempt (but it's just
a guess).

Discussion

  • Andy Dustman
    Andy Dustman
    2004-10-18

    Logged In: YES
    user_id=71372

    Try 1.1.6 instead of 1.0.0, and also Python-2.3.4, and see
    if it still happens.

     
  • Andy Dustman
    Andy Dustman
    2004-10-28

    Logged In: YES
    user_id=71372

    Thus far, I cannot replicate this with:

    Linux (x86)
    MySQLdb-1.1.6
    MySQL-4.1.7
    Python-2.4b1

     
  • Skip Montanaro
    Skip Montanaro
    2004-12-14

    Logged In: YES
    user_id=44345

    Sorry it took so long to get back to this. I just tried with 1.1.7
    and Python 2.4. First problem was the apparent
    lack of libcrypt during the build. (I can't find it on my system or
    in fink, so perhaps it's not needed on MacOSX?)

    I manually linked without -lcrypt just to seewhat would happen
    then tried to create a connection. The result:

    % python2.4 chkmysql.py
    Traceback (most recent call last):
    File "chkmysql.py", line 8, in ?
    db="concerts")
    File "/Users/skip/local/lib/python2.4/site-packages/MySQLdb/
    init.py", line 64, in Connect
    return Connection(args, kwargs)
    File "/Users/skip/local/lib/python2.4/site-packages/MySQLdb/
    connections.py", line 108, in
    init
    self.converter[types.StringType] = self.string_literal
    TypeError: object does not support item assignment
    malloc[2135]: error for object 0x573ef0: Incorrect checksum
    for freed object - object was probably modified after being freed;
    break at szone_error

    I then built Python 2.3.4 and installed MySQLdb-python 1.1.7 with
    it. Same result:

    % python2.3 chkmysql.py
    Traceback (most recent call last):
    File "chkmysql.py", line 8, in ?
    db="concerts")
    File "/Users/skip/local/lib/python2.3/site-packages/MySQLdb/
    init.py", line 64, in Connect
    return Connection(args, *kwargs)
    File "/Users/skip/local/lib/python2.3/site-packages/MySQLdb/
    connections.py", line 108, in init
    self.converter[types.StringType] = self.string_literal
    TypeError: object does not support item assignment

     
  • Andy Dustman
    Andy Dustman
    2004-12-14

    Logged In: YES
    user_id=71372

    Try throwing this into the darwin section:

    libraries.remove("crypt")
    

    and see if it will build without errors. I'll put this in
    1.1.8 if that works at least; there is a similar line for
    Windows. Sometimes libcrypt is not a separate library, i.e.
    it is incorporated into the C library.