Dynamic loading of modules in AIX

Neal Norwitz neal at metaslash.com
Thu Nov 7 22:04:23 EST 2002


I'm trying to get python to load dynamic modules.
But after loading the module, when code inside
the module calls back into the main program,
it seg faults.  More details below.

Anybody have any ideas what could cause this?
At one point, I believe this worked.  It's possible
the machines aren't configured properly or don't
have the necessary patches.

Currently, the interpreter builds and seems to work fine.
However, it can't load modules.  Well, actually it can
load modules, but as soon as the module calls a python
utility (an API in libpython), it seg faults.

Specifically (I cleaned the lines up and took out some stuff):

        neal at dupont [~/python/dist/src]$ make
        # snip line
        running build
        running build_ext
        building 'struct' extension
        gcc -g -c Modules/structmodule.c

        ./Modules/ld_so_aix gcc -bI:Modules/python.exp structmodule.o \
                -L/usr/local/lib -o build/lib.aix-4.3-2.3/struct.so
        gcc -Wl,-einitstruct -Wl,-bE:struct.exp -Wl,-bI:Modules/python.exp \
                -Wl,-bhalt:4 -Wl,-bM:SRE -Wl,-T512 -Wl,-H512 -lm \
                -o build/lib.aix-4.3-2.3/struct.so \
                build/temp.aix-4.3-2.3/structmodule.o -L/usr/local/lib
        ./python -c 'import struct'
        make: *** [sharedmods] Segmentation fault

gcc version is 3.2.  I tried xlc, but got the same results.  I think
xlc's version is 5.7.6.5 (5765-C6400).  My LIBPATH was empty.  I also
set LIBPATH to the directory where libpython2.3.a lives, but it
doesn't help.

This is on AIX 4.3.1.0, but I've had the problem on 4.3.3.x and 4.2.1.0.

Here's some more details:

        #0  0xd009be70 in Py_InitModule4TraceRefs ()
                from build/lib.aix-4.3-2.3/struct.so
        #1  0xd009ac3c in initstruct ()
                at /home/neal/python/dist/src/Modules/structmodule.c:1535
        #2  0x101182e0 in _PyImport_LoadDynamicModule (name=0x2026d70c "struct",
                pathname=0x20161594 "build/lib.aix-4.3-2.3/struct.so", fp=0x0)
                at Python/importdl.c:53

This indicates that the dynamic load of struct.so was successful. (#2)
The call to initstruct() in struct.so was successful. (#1)  But
inside the module, when we try to call Py_InitModule4TraceRefs()
(or Py_InitModule in the code), it crashes.  I don't know why.

Suggestions?

Thanks,
Neal



More information about the Python-list mailing list