473,386 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Own C-extension module causes SIGABRT when imported.

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
Jul 18 '05 #1
0 1532

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Chris | last post by:
hi, to convert excel files via csv to xml or whatever I frequently use the csv module which is really nice for quick scripts. problem are of course non ascii characters like german umlauts, EURO...
0
by: John Phelan | last post by:
I had a very large number of query statements that I had converted to SQL a long time ago aticipating that I would some day upsize my application. Every now and then when I do an import to a new...
3
by: Zachary Pincus | last post by:
Hi folks, I'm sure this has come up before, but the search terms I've been using are so non-specific that I can't get any traction on Google. Here's my question: I have written a subclass of...
17
by: OlafMeding | last post by:
Below are 2 files that isolate the problem. Note, both programs hang (stop responding) with hyper-threading turned on (a BIOS setting), but work as expected with hyper-threading turned off. ...
10
by: Michael Abbott | last post by:
It seems to be an invariant of Python (insofar as Python has invariants) that a module is executed at most once in a Python session. I have a rather bizzare example that breaks this invariant: can...
0
by: Anand Patil | last post by:
Hi all, I was referred to this list from python-help. I've written an extension module in C which contains several new types. The types can be instantiated, used, and deleted under Python 2.4.3 ...
0
by: adamselearning | last post by:
I have HTML content defined in an external XML file: I am using code to identify when a <p> tag is present, so it is not treated as an XML node. I'm also using CDATA in some cases, and still...
3
by: Johny | last post by:
Is it possible to unload a module after I've imported it. I have the main program from which I import several smaller programs. Some of these uses timeoutsocket module. But one of the smaller...
1
by: graph | last post by:
Per http://mail.python.org/pipermail/python-list/2008-September/506206.html something like this (plus error handling) seems to be the right way to add to sys.path when embedding python in C: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.