AIX -illegal instruction - importing extension module

Ajay Bakhshi abakhshi at legato.com
Mon Mar 15 22:53:06 CET 2004


Hi,

I am getting the following problem on AIX.
I create a small shared library. And tried to load it in python.

It core dumps with the following message:
Segmentation fault (core dumped)

At other time with another shared lib I got:
Illegal instruction: core dump

* The program works fine on hp-ux 11.11 and solaris 7.

NOTE:
* python - version: 2.2.3 is compiled with cc_r (Visual age 6.0 compiler)
	it is #####  64 bit  ######
* AIX	5
* I compiled the shared lib with xlC, cc_r and g++ to see if the compiler
was an issue
* Also note that: when I copy the pwd.so from lib-dynload/pwd.so and moved
lib-dynload/pwd.so to lib-dynload/pwd.so.org and then imported pwd.so it
when through fine.
* When I wrote a C main() program to load the shared library and load the
symbol using dlopen and dlsym it worked fine.


The python program is:
=========================================
import os, sys
print "before import libspam"
import libspam				====> It dumps here
print "after import libspam"
print OK.
=========================================

The shared lib code is also very simple

=================================================================
PyObject *
spam_system(PyObject *self, PyObject *args)
{
    char *command;
    int sts;

    printf("\n In spam_system \n");
    if (!PyArg_ParseTuple(args, "s", &command))
    {
	printf("\n  spam_system: FAILURE");
        return NULL;
    }
    sts = system(command);
    printf("\n  spam_system: SUCCESS");

    return Py_BuildValue("i", sts);
}

static PyMethodDef mmdb_methods[] =
{
	{	"spam",	spam_system,    METH_VARARGS,
		"mmdb.control( allow_fail, allow_fall_back ) -- Control the
kind of client that is created"
	},
	{	0, 0, 0, 0	}
};

PyObject * initlibspam(void)
{
    PyObject *module = Py_InitModule3("libspam", mmdb_methods, "Test Spam");

    return module;
}
=================================================================


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20040315/7fb4b783/attachment.html>


More information about the Python-list mailing list