Menu

#65 import MySQLdb segfault Solaris 7

MySQLdb-0.9.2
closed
MySQLdb (285)
5
2014-12-26
2003-08-27
Anonymous
No

MySQLdb 0.9.2 compiles fine but segfaults on import.

Python 2.2.3 (#1, Aug 26 2003, 23:07:17)
[GCC 2.95.3 20010315 (release)] on sunos5
Type "help", "copyright", "credits" or "license" for
more information.
>>> import MySQLdb
Segmentation Fault (core dumped)

I am currently working with Solaris 7, Python 2.2.3
compiled from source, MySQL 3.23.57 compiled from
source, and GCC 2.95.3.

I have also tried Python 2.2.2 and GCC 3.2.2 to no
avail. Configure for MySQL looks like this:

./configure
--prefix=/usr/local/mysql-3.23.57--with-libwrap=/usr/local/lib
--with-named-z-libs=/usr/local/lib
--with-named-curses=/usr/local/lib
--enable-thread-safe-client --with-low-memory
--enable-assembler

I have everything working on Redhat 9 and I know
Solaris 7 is really old, but I thought I would report
this in case anyone has experienced similar problems.

Discussion

  • Lance French

    Lance French - 2003-08-28

    Logged In: YES
    user_id=853523

    Adding a comment so you have my sourceforge information.

     
  • Andy Dustman

    Andy Dustman - 2003-11-22

    Logged In: YES
    user_id=71372

    it's really impossible for me to guess what might be the
    problem without a backtrace. If you have gdb, then do this
    (doing this on Linux/i386):

    $ gdb python
    GNU gdb 5.3
    Copyright 2002 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public
    License, and you are
    welcome to change it and/or distribute copies of it under
    certain conditions.
    Type "show copying" to see the conditions.
    There is absolutely no warranty for GDB. Type "show
    warranty" for details.
    This GDB was configured as "i686-pc-linux-gnu"...
    (gdb) run
    Starting program: /usr/bin/python
    [New Thread 16384 (LWP 15737)]
    Python 2.2.3 (#1, Nov 15 2003, 16:54:31)
    [GCC 3.3.2 20031022 (Gentoo Linux 3.3.2-r2, propolice)] on
    linux2
    Type "help", "copyright", "credits" or "license" for more
    information.
    >>> import MySQLdb

    Once it crashes, use the bt command to produce a backtrace,
    like this (your output WILL look different):

    (gdb) bt

    0 0x40037a28 in read () from /lib/libpthread.so.0

    1 0x402d31d0 in JCR_LIST () from /lib/libreadline.so.4

    2 0x402c6053 in rl_read_key () from /lib/libreadline.so.4

    ....

    13 0x080a6ae8 in PyRun_AnyFileExFlags ()

    14 0x080534c6 in Py_Main ()

    15 0x0805305b in main ()

    16 0x40177adf in __libc_start_main () from /lib/libc.so.6

    Add the backtrace to this bug. I can't guarantee I can do
    much with it, though, but I'll look at it.

     
  • Lance French

    Lance French - 2003-12-02

    Logged In: YES
    user_id=853523

    Sorry it took me so long to get back to you on this. Here is the
    output of the back trace.

     
  • Lance French

    Lance French - 2003-12-02

    Logged In: YES
    user_id=853523

    import MySQLdb

    Program received signal SIGSEGV, Segmentation fault.
    PyModule_GetDict (m=0x0) at Objects/moduleobject.c:47
    47 if (!PyModule_Check(m)) {
    (gdb) bt

    0 PyModule_GetDict (m=0x0) at Objects/moduleobject.c:47

    1 0xff024054 in init_mysql () at _mysql.c:2204

    2 0x9d364 in _PyImport_LoadDynamicModule (name=0xffbed9c8

    "_mysql",
    pathname=0xffbed4d0 "/usr/local/lib/python2.3/site-packages/
    _mysql.so",
    fp=0xff02400c) at ./Python/importdl.c:53

    3 0x9aa38 in load_module (name=0xffbed9c8 "_mysql",

    fp=0x113f10,
    buf=0xffbed4d0 "/usr/local/lib/python2.3/site-packages/
    _mysql.so", type=3,
    loader=0x0) at Python/import.c:1708

    4 0x9ba74 in import_submodule (mod=0xf599c,

    subname=0xffbed9c8 "_mysql",
    fullname=0xffbed9c8 "_mysql") at Python/import.c:2290

    5 0x9b5b4 in load_next (mod=0x1abe50, altmod=0xf599c,

    p_name=0xffbed9c8,
    buf=0xffbed9c0 "MySQLdb._mysql", p_buflen=0xffbed9bc)
    at Python/import.c:2115

    6 0x9afd0 in import_module_ex (name=0x0, globals=0x13fc90,

    locals=0x13fc90,
    fromlist=0xf599c) at Python/import.c:1957

    7 0x9b214 in PyImport_ImportModuleEx (name=0x1b0314

    "_mysql",
    globals=0x13fc90, locals=0x13fc90, fromlist=0xf599c)
    at Python/import.c:1998

    8 0x77518 in builtin_import (self=0x0, args=0x1a5f00)

    at Python/bltinmodule.c:45
    

    9 0xcbd44 in PyCFunction_Call (func=0x120e68, arg=0x1a5f00,

    kw=0x0)
    at Objects/methodobject.c:108

    10 0x235c8 in PyObject_Call (func=0x120e68, arg=0x1a5f00,

    kw=0x0)
    at Objects/abstract.c:1755

    11 0x806fc in PyEval_CallObjectWithKeywords (func=0x120e68,

    arg=0x1a5f00,
    kw=0x0) at Python/ceval.c:3346

    12 0x7e05c in eval_frame (f=0x1e5438) at Python/ceval.c:1996

    13 0x7f958 in PyEval_EvalCodeEx (co=0x1a3660, globals=0x0,

    locals=0x1e5438,
    args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0,
    defcount=0,
    closure=0x0) at Python/ceval.c:2663

    14 0x8277c in PyEval_EvalCode (co=0x1a3660,

    globals=0x13fc90, locals=0x13fc90)
    at Python/ceval.c:537

    15 0x99760 in PyImport_ExecCodeModuleEx (name=0xffbef178

    "MySQLdb",
    co=0x1a3660,
    pathname=0xffbee298 "/usr/local/lib/python2.3/site-packages/
    MySQLdb/init.pyc") at Python/import.c:621

    16 0x99cb4 in load_source_module (name=0xffbef178

    "MySQLdb",
    pathname=0xffbee298 "/usr/local/lib/python2.3/site-packages/
    MySQLdb/init.pyc", fp=0x113f00) at Python/import.c:894

    17 0x9aa08 in load_module (name=0xffbef178 "MySQLdb",

    fp=0x113f00,
    buf=0xffbee790 "/usr/local/lib/python2.3/site-packages/
    MySQLdb/init.py", type=1, loader=0x0) at Python/import.c:
    1699

    18 0x99e38 in load_package (name=0xffbef178 "MySQLdb",

    pathname=0x129f50 "")
    at Python/import.c:951

    19 0x9aa4c in load_module (name=0xffbef178 "MySQLdb",

    fp=0x0,
    buf=0xffbeec88 "/usr/local/lib/python2.3/site-packages/
    MySQLdb", type=5,
    loader=0x0) at Python/import.c:1722

    20 0x9ba74 in import_submodule (mod=0xf599c,

    subname=0xffbef178 "MySQLdb",
    fullname=0xffbef178 "MySQLdb") at Python/import.c:2290

    21 0x9b560 in load_next (mod=0xf599c, altmod=0xf599c,

    p_name=0xffbef178,
    buf=0xffbef178 "MySQLdb", p_buflen=0xffbef174) at Python/
    import.c:2111

    22 0x9afd0 in import_module_ex (name=0x0, globals=0x1319c0,

    locals=0x1319c0,
    fromlist=0xf599c) at Python/import.c:1957

    23 0x9b214 in PyImport_ImportModuleEx (name=0x1abe94

    "MySQLdb",
    globals=0x1319c0, locals=0x1319c0, fromlist=0xf599c)
    at Python/import.c:1998

    24 0x77518 in builtin_import (self=0x0, args=0x130900)

    at Python/bltinmodule.c:45
    

    25 0xcbd44 in PyCFunction_Call (func=0x120e68, arg=0x130900,

    kw=0x0)
    at Objects/methodobject.c:108

    26 0x235c8 in PyObject_Call (func=0x120e68, arg=0x130900,

    kw=0x0)
    at Objects/abstract.c:1755

    27 0x806fc in PyEval_CallObjectWithKeywords (func=0x120e68,

    arg=0x130900,
    kw=0x0) at Python/ceval.c:3346

    28 0x7e05c in eval_frame (f=0x1e2f48) at Python/ceval.c:1996

    29 0x7f958 in PyEval_EvalCodeEx (co=0x1a3b60, globals=0x0,

    locals=0x1e2f48,
    args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0,
    defcount=0,
    closure=0x0) at Python/ceval.c:2663

    30 0x8277c in PyEval_EvalCode (co=0x1a3b60,

    globals=0x1319c0, locals=0x1319c0)
    at Python/ceval.c:537

    31 0xa5758 in run_node (n=0x121158, filename=0x1a3b60 "",

    globals=0x1319c0,
    locals=0x1319c0, flags=0xffbefbd4) at Python/pythonrun.c:1239

    32 0xa3a38 in PyRun_InteractiveOneFlags (fp=0x121158,

    filename=0xcf0a8 "<stdin>", flags=0xffbefbd4) at Python/
    

    pythonrun.c:731

    33 0xa5088 in PyRun_InteractiveLoopFlags (fp=0x113ed0,

    filename=0xcf0a8 "<stdin>", flags=0xffbefbd4) at Python/
    

    pythonrun.c:664

    34 0xa4e30 in PyRun_AnyFileExFlags (fp=0x113ed0,

    filename=0xcf0a8 "<stdin>",
    closeit=0, flags=0xffbefbd4) at Python/pythonrun.c:627

    35 0x1cb28 in Py_Main (argc=1, argv=0xffbefcbc) at Modules/

    main.c:415

    36 0x1c360 in main (argc=1, argv=0xffbefcbc) at Modules/

    python.c:23

     
  • Lance French

    Lance French - 2003-12-02

    Logged In: YES
    user_id=853523

    I wish I were smart enough to be able to attach a file here. If you
    are interested I can post a file of the output to the web as opposed
    to the paste.

    Thanks again, Lance.

     
  • Andy Dustman

    Andy Dustman - 2003-12-13

    Logged In: YES
    user_id=71372

    This appears to be the relevant code:

    2194 DL_EXPORT(void)
    2195 init_mysql(void)
    2196 {
    2197 PyObject dict, module, emod, edict;

    2198 adustman 1.31 module = Py_InitModule4("_mysql",
    _mysql_methods, _mysql_doc,
    2199 (PyObject *)NULL, PYTHON_API_VERSION);

    2200 adustman 1.1 #ifdef MS_WIN32
    2201 _mysql_ConnectionObject_Type.ob_type =
    &PyType_Type;
    2202 _mysql_ResultObject_Type.ob_type =
    &PyType_Type;
    2203 #endif
    2204 if (!(dict = PyModule_GetDict(module)))
    goto error;

    So I guess Py_InitModule4() is failing and returing
    module=NULL, and this crashes PyModule_GetDict(). I guess
    I'll have to do some error handling there so we can find out
    why Py_InitModule4() fails.

     
  • Andy Dustman

    Andy Dustman - 2003-12-13

    Logged In: YES
    user_id=71372

    Try inserting this line before that PyModule_GetDict() line
    (2204):

    if (!module) return NULL;

    That might be sufficient to provide some more information.

     
  • Andy Dustman

    Andy Dustman - 2003-12-13

    Logged In: YES
    user_id=71372

    Actually, you should insert this at 2201 (init_mysql() does
    not return a value):

    if (!module) return;

     
  • Lance French

    Lance French - 2003-12-14

    Logged In: YES
    user_id=853523

    Inserted your return just before the MS_WIN32 stuff at line
    2200. Here is the output now:

    >>> import MySQLdb
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    File "MySQLdb/init.py", line 27, in ?
    import _mysql
    ValueError: module functions cannot set METH_CLASS or
    METH_STATIC

     
  • Andy Dustman

    Andy Dustman - 2003-12-14

    Logged In: YES
    user_id=71372

    How very interesting.

    At this point, I would suspect that your Python is compiled
    with some odd options.

    I just grep'd through the Python-2.2.3 sources and don't see
    anything like your error message. What version of Python was
    that? And see if you can reproduce this with the latest
    0.9.3 beta. Don't worry about it being beta; it fixes known
    bugs in 0.9.2 and (probably) doesn't add any.

     
  • Lance French

    Lance French - 2003-12-14

    Logged In: YES
    user_id=853523

    That error message is part of Python/modsupport.c where it
    runs through the methods you are importing and checks for
    proper names and such. (See Py_Initmodule4())

    I played with _mysql.c for a bit and was able to get around
    the error, and even import MySQLdb, by making some changes
    to the _mysql_methods[] array. (Changed the position of the
    sentinel.) However, I would still core dump as soon as I
    tried to do anything like connect to a database.

    I have the same results with 0.9.3b2. I am able to import
    and then blow up if I try to connect. I will paste the bt
    momentarily, because it is the same for both versions, but
    since it flows from libc to libmysqlclient I am guessing
    something is not quite right about my compiler set up to
    begin with. :(

     
  • Lance French

    Lance French - 2003-12-14

    Logged In: YES
    user_id=853523

    Currently working with Python-2.3.2, but I can downgrade again.

    >>>
    conn=MySQLdb.connect(user="root",passwd="yeahright",host="localhost",db="mydb");
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    File "MySQLdb/init.py", line 63, in Connect
    return apply(Connection, args, kwargs)
    File "MySQLdb/connections.py", line 116, in init
    self.converter[types.StringType] = self.string_literal
    TypeError: object does not support item assignment
    >>> type something here and hit enter

    Program received signal SIGBUS, Bus error.
    0xff146678 in _free_unlocked () from /usr/lib/libc.so.1
    (gdb) bt

    0 0xff146678 in _free_unlocked () from /usr/lib/libc.so.1

    1 0xff146630 in free () from /usr/lib/libc.so.1

    2 0xfe7cb73c in my_no_flags_free ()

    from /usr/local/mysql/lib/mysql/libmysqlclient.so.10

    3 0xfe7c80ec in mysql_close ()

    from /usr/local/mysql/lib/mysql/libmysqlclient.so.10

    4 0xff0247cc in _mysql_ConnectionObject_close

    (self=0x210470, args=0x118030)
    at _mysql.c:553

    5 0xcbd44 in PyCFunction_Call (func=0x1d1f80,

    arg=0x118030, kw=0x0)
    at Objects/methodobject.c:108

    6 0x80878 in call_function (pp_stack=0xffbeefe0,

    oparg=1146928)
    at Python/ceval.c:3439

    7 0x7e3a4 in eval_frame (f=0x2102b0) at Python/ceval.c:2116

    8 0x7f958 in PyEval_EvalCodeEx (co=0x1b4ca0, globals=0x0,

    locals=0x2102b0,
    args=0x1c217c, argcount=1, kws=0x0, kwcount=0, defs=0x0,
    defcount=0,
    closure=0x0) at Python/ceval.c:2663

    9 0xcb120 in function_call (func=0x1c1530, arg=0x1c2170,

    kw=0x0)
    at Objects/funcobject.c:504

    10 0x235c8 in PyObject_Call (func=0x1c1530, arg=0x1c2170,

    kw=0x0)
    at Objects/abstract.c:1755

    11 0x2b8d4 in instancemethod_call (func=0x1c1530,

    arg=0x1c2170, kw=0x0)
    at Objects/classobject.c:2433

    12 0x235c8 in PyObject_Call (func=0x1c1530, arg=0x1c2170,

    kw=0x0)
    at Objects/abstract.c:1755

    13 0x806fc in PyEval_CallObjectWithKeywords (func=0x12e710,

    arg=0x118030,
    kw=0x0) at Python/ceval.c:3346

    14 0x5ecf8 in slot_tp_del (self=0x210470) at

    Objects/typeobject.c:4729

    15 0x53a0c in subtype_dealloc (self=0x210470) at

    Objects/typeobject.c:660

    16 0xc9530 in frame_dealloc (f=0x1810d0) at

    Objects/frameobject.c:394

    17 0xa7b4c in tb_dealloc (tb=0x1d6788) at Python/traceback.c:41

    18 0xa7b14 in tb_dealloc (tb=0x1d67b0) at Python/traceback.c:40

    19 0xa7b14 in tb_dealloc (tb=0x1d67d8) at Python/traceback.c:40

    20 0x4246c in PyDict_SetItem (op=0x11a780, key=0x1af160,

    value=0x1ade90)
    at Objects/dictobject.c:379

    21 0x44c9c in PyDict_SetItemString (v=0x11a780, key=0xdbba0

    "last_traceback",
    item=0x1ade90) at Objects/dictobject.c:1976

    22 0xa72e4 in PySys_SetObject (name=0xdbba0

    "last_traceback", v=0x1ade90)
    at Python/sysmodule.c:82

    23 0xa42f0 in PyErr_PrintEx (set_sys_last_vars=1) at

    Python/pythonrun.c:1036

    24 0xa5434 in PyErr_Print () at Python/pythonrun.c:941

    25 0xa3a4c in PyRun_InteractiveOneFlags (fp=0xffffffff,

    filename=0xcf0a8 &quot;&lt;stdin&gt;&quot;, flags=0xffbefbbc) at
    

    Python/pythonrun.c:733

    26 0xa5088 in PyRun_InteractiveLoopFlags (fp=0x113ed0,

    filename=0xcf0a8 &quot;&lt;stdin&gt;&quot;, flags=0xffbefbbc) at
    

    Python/pythonrun.c:664

    27 0xa4e30 in PyRun_AnyFileExFlags (fp=0x113ed0,

    filename=0xcf0a8 "<stdin>",
    closeit=0, flags=0xffbefbbc) at Python/pythonrun.c:627

    28 0x1cb28 in Py_Main (argc=1, argv=0xffbefca4) at

    Modules/main.c:415

    29 0x1c360 in main (argc=1, argv=0xffbefca4) at

    Modules/python.c:23
    (gdb) Quit

     
  • Andy Dustman

    Andy Dustman - 2003-12-15

    Logged In: YES
    user_id=71372

    OK, I see that code in 2.3.2; it was not in 2.2.3. However,
    I've tested with 2.3.2 and don't get anything like that on
    i386. There's nothing in the code that makes that
    platform-dependent, though.

     
  • Andy Dustman

    Andy Dustman - 2003-12-15

    Logged In: YES
    user_id=71372

    Take a look at this bug:

    https://sourceforge.net/tracker/?group_id=22307&atid=374932&func=detail&aid=761258

    The symptoms are very similar. Are you sure all these things
    are compiled with the same compiler: Python, MySQL, MySQLdb ?

     
  • Lance French

    Lance French - 2003-12-15

    Logged In: YES
    user_id=853523

    Yes, the error is now identical to the one in the bug you
    mentioned. So you may close this ticket, there has to be
    something wrong with my GCC installation (wrong libs for the
    compiler or something, damn sunfreeware). I'll try
    compiling gcc from scratch and see how I do.

    As for the _mysql_methods[] problem, that already seems to
    be cleared up in your 0.9.3 code.

    I appreciate the help.

     
  • Lance French

    Lance French - 2003-12-16

    Logged In: YES
    user_id=853523

    FYI, I recompiled everything with gcc 3.3.2 on solaris, but
    mysql_real_connect() still bombs with malloc() errors.
    Something is not jiving between libc and mysqlclient on
    Solaris. libc6 (linux) systems seem to have no problem.
    From the other bug you mentioned, looks like the Mac OS X
    (freebsd) people are in the same boat to a certain extent.
    I am giving up on this one.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.