#65 import MySQLdb segfault Solaris 7

MySQLdb-0.9.2
closed
Andy Dustman
MySQLdb (285)
5
2012-09-19
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

1 2 > >> (Page 1 of 2)
  • 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.

     
1 2 > >> (Page 1 of 2)