Own C-extension module causes SIGABRT when imported.

Discussion in 'Python' started by Berteun Damman, Dec 17, 2003.

  1. Hello,

    First I was trying to get PyOSD, but as soon as I did `import pyosd'
    Python received a SIGABRT. Then I wrote my own module, which looks like:

    #include <Python.h>
    static PyMethodDef testmod_methods[] = { {NULL, NULL} };

    void initmymod(void) {
    Py_InitModule("mymod", testmod_methods);
    }

    So, nothing fancy here. When I just compile it, it can be imported, and
    it works (i.e. I can do print mymod.__name__). But as soon as I only
    link the module to libxosd, it causes an SIGABRT, linking it to, say,
    libkhtml or libxmltok doesn't cause any problems. Therefore I suspect
    the problem lies with libxosd (version 2.2.5).

    Furthermore, the problem both occurs with Python 2.3.2 and Python 2.2.3.
    I've compiled both with debugging information, and gdb shows the
    following stacktraces (I do gdb python2.3 and then r -c 'import mymod').

    Python 2.3.2 stacktrace:
    Program received signal SIGABRT, Aborted.
    0x4821390b in kill () from /usr/lib/libc.so.12
    (gdb) bt
    #0 0x4821390b in kill () from /usr/lib/libc.so.12
    #1 0x48215cf6 in __libc_mutex_unlock () from /usr/lib/libc.so.12
    #2 0x48292916 in __flockfile_internal () from /usr/lib/libc.so.12
    #3 0x48280803 in fclose () from /usr/lib/libc.so.12
    #4 0x48101669 in import_submodule (mod=0x4813fb28,
    subname=0xbfbfee90 "mymod", fullname=0xbfbfee90 "mymod")
    at Python/import.c:2293
    #5 0x48100f30 in load_next (mod=0x4813fb28, altmod=0x4813fb28,
    p_name=0xbfbff2b0, buf=0xbfbfee90 "mymod", p_buflen=0xbfbfee8c)
    at Python/import.c:2111
    #6 0x4810097d in import_module_ex (name=0x0, globals=0x806a79c,
    locals=0x806a79c, fromlist=0x4813fb28) at Python/import.c:1957
    #7 0x48100b9a in PyImport_ImportModuleEx (name=0x80f0114 "mymod",
    globals=0x806a79c, locals=0x806a79c, fromlist=0x4813fb28)
    at Python/import.c:1998
    #8 0x480d94dd in builtin___import__ (self=0x0, args=0x80726bc)
    at Python/bltinmodule.c:45
    #9 0x480aade7 in PyCFunction_Call (func=0x805abec, arg=0x80726bc, kw=0x0)
    at Objects/methodobject.c:73
    #10 0x48083169 in PyObject_Call (func=0x805abec, arg=0x80726bc, kw=0x0)
    at Objects/abstract.c:1755
    #11 0x480e7825 in PyEval_CallObjectWithKeywords (func=0x805abec,
    arg=0x80726bc, kw=0x0) at Python/ceval.c:3346
    #12 0x480e4cfb in eval_frame (f=0x809540c) at Python/ceval.c:1996
    #13 0x480e6548 in PyEval_EvalCodeEx (co=0x80e91a0, globals=0x806a79c,
    locals=0x806a79c, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0,
    defcount=0, closure=0x0) at Python/ceval.c:2663
    #14 0x480e1a6b in PyEval_EvalCode (co=0x80e91a0, globals=0x806a79c,
    locals=0x806a79c) at Python/ceval.c:537
    #15 0x48109ac5 in run_node (n=0x8052350, filename=0x48135c4b "<string>",
    globals=0x806a79c, locals=0x806a79c, flags=0xbfbff634)
    at Python/pythonrun.c:1239
    #16 0x48109a5c in run_err_node (n=0x8052350, filename=0x48135c4b "<string>",
    globals=0x806a79c, locals=0x806a79c, flags=0xbfbff634)
    at Python/pythonrun.c:1226
    #17 0x48109935 in PyRun_StringFlags (str=0x804f030 "import mymod\n",
    start=257, globals=0x806a79c, locals=0x806a79c, flags=0xbfbff634)
    at Python/pythonrun.c:1196
    #18 0x48108a52 in PyRun_SimpleStringFlags (command=0x804f030 "import mymod\n",
    flags=0xbfbff634) at Python/pythonrun.c:863
    #19 0x4810f9d1 in Py_Main (argc=3, argv=0xbfbff6dc) at Modules/main.c:399
    #20 0x08049042 in main ()
    #21 0x08048d2a in ___start ()

    Lines 2292-2293 of import.c are:
    2292 if (fp)
    2293 fclose(fp);

    With Python 2.2.3 gdb gives this stacktrace:
    Program received signal SIGABRT, Aborted.
    0x481d490b in kill () from /usr/lib/libc.so.12
    (gdb) bt
    #0 0x481d490b in kill () from /usr/lib/libc.so.12
    #1 0x481d6cf6 in __libc_mutex_unlock () from /usr/lib/libc.so.12
    #2 0x48254f6f in malloc () from /usr/lib/libc.so.12
    #3 0x080597de in PyString_FromString (str=0x48276856 "mymod")
    at Objects/stringobject.c:135
    #4 0x080ea9d7 in PyDict_GetItemString (v=0x812f60c, key=0x48276856 "mymod")
    at Objects/dictobject.c:1866
    #5 0x080a1e1f in PyImport_AddModule (name=0x48276856 "mymod")
    at Python/import.c:480
    #6 0x080a8cc2 in Py_InitModule4TraceRefs (name=0x48276856 "mymod",
    methods=0x482779c4, doc=0x0, passthrough=0x0, module_api_version=1011)
    at Python/modsupport.c:56
    #7 0x48276826 in initmymod () at mymod.c:5
    #8 0x080a5d48 in _PyImport_LoadDynamicModule (name=0xbfbfeeb0 "mymod",
    pathname=0xbfbfea10 "mymod.so", fp=0x4826f460) at Python/importdl.c:53
    #9 0x080a3301 in load_module (name=0xbfbfeeb0 "mymod", fp=0x4826f460,
    buf=0xbfbfea10 "mymod.so", type=3) at Python/import.c:1410
    #10 0x080a484d in import_submodule (mod=0x810c284, subname=0xbfbfeeb0 "mymod",
    fullname=0xbfbfeeb0 "mymod") at Python/import.c:1947
    #11 0x080a408d in load_next (mod=0x810c284, altmod=0x810c284,
    p_name=0xbfbff2d0, buf=0xbfbfeeb0 "mymod", p_buflen=0xbfbfeeac)
    at Python/import.c:1803
    #12 0x080a3a34 in import_module_ex (name=0x0, globals=0x8142c0c,
    locals=0x8142c0c, fromlist=0x810c284) at Python/import.c:1649
    #13 0x080a3d46 in PyImport_ImportModuleEx (name=0x815051c "mymod",
    globals=0x8142c0c, locals=0x8142c0c, fromlist=0x810c284)
    at Python/import.c:1690
    #14 0x080ed1bc in builtin___import__ (self=0x0, args=0x813a84c)
    at Python/bltinmodule.c:40
    #15 0x080eafdc in PyCFunction_Call (func=0x812b200, arg=0x813a84c, kw=0x0)
    at Objects/methodobject.c:79
    #16 0x080c62e1 in PyObject_Call (func=0x812b200, arg=0x813a84c, kw=0x0)
    at Objects/abstract.c:1688
    #17 0x0808bf4f in PyEval_CallObjectWithKeywords (func=0x812b200,
    arg=0x813a84c, kw=0x0) at Python/ceval.c:3058
    #18 0x08087c89 in eval_frame (f=0x8132c0c) at Python/ceval.c:1843
    #19 0x0808a828 in PyEval_EvalCodeEx (co=0x814bb00, globals=0x8142c0c,
    locals=0x8142c0c, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0,
    defcount=0, closure=0x0) at Python/ceval.c:2595
    #20 0x08080787 in PyEval_EvalCode (co=0x814bb00, globals=0x8142c0c,
    locals=0x8142c0c) at Python/ceval.c:481
    #21 0x080aced5 in run_node (n=0x817e480, filename=0x8101ecd "<string>",
    globals=0x8142c0c, locals=0x8142c0c, flags=0xbfbff63c)
    at Python/pythonrun.c:1067
    #22 0x080ace7f in run_err_node (n=0x817e480, filename=0x8101ecd "<string>",
    globals=0x8142c0c, locals=0x8142c0c, flags=0xbfbff63c)
    at Python/pythonrun.c:1054
    #23 0x080acdb8 in PyRun_StringFlags (str=0x812c030 "import mymod\n",
    start=257, globals=0x8142c0c, locals=0x8142c0c, flags=0xbfbff63c)
    at Python/pythonrun.c:1021
    #24 0x080abd05 in PyRun_SimpleStringFlags (command=0x812c030 "import mymod\n",
    flags=0xbfbff63c) at Python/pythonrun.c:700
    #25 0x08052f8b in Py_Main (argc=3, argv=0xbfbff6dc) at Modules/main.c:351
    #26 0x08052852 in main (argc=3, argv=0xbfbff6dc) at Modules/python.c:10
    #27 0x0805254a in ___start ()

    stringobject has on the lines 135-136:
    135 op = (PyStringObject *)
    136 PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char));

    Well, I really don't understand why this only goes wrong when linking to xosd
    (and not even using any kind of its functionality). The osd_cat program
    provided with libxosd works.

    The system I'm working on is NetBSD-current (1.6ZG, compiled yesterday).
    Perhaps it has nothing to do with Python, but more with libxosd, but it the end
    it's Python that causes the error. :)

    Berteun Damman
     
    Berteun Damman, Dec 17, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roger Davis

    new causing SIGABRT

    Roger Davis, Sep 6, 2003, in forum: C++
    Replies:
    1
    Views:
    438
    llewelly
    Sep 7, 2003
  2. Replies:
    2
    Views:
    735
    mlimber
    Nov 4, 2005
  3. Charlie
    Replies:
    5
    Views:
    590
    Ben Pope
    Feb 22, 2006
  4. Dun Peal
    Replies:
    10
    Views:
    468
    Chris Rebert
    May 3, 2011
  5. Volker Nicolai
    Replies:
    9
    Views:
    1,081
    Fabian Pilkowski
    Jul 4, 2005
Loading...

Share This Page