Dynamic loading of modules in AIX

Dynamic loading of modules in AIX

Post by Neal Norwit » Sat, 09 Nov 2002 12:04:23



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):


        # 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

 
 
 

Dynamic loading of modules in AIX

Post by Stuart D. Gathma » Sat, 09 Nov 2002 15:13:03



> 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.

You need to use ld_so_aix, which imports the symbols for the main program
into the loadable modules.  Otherwise, those symbols are unresolved
giving a coredump when called.

You can find my RPM spec file for python-2.2 at
http://www.veryComputer.com/

(along with binary RPMs and a tar of rpm itself.  RPM needs LANG=C on
some AIX versions.)

Even if you don't use RPM on AIX, the spec file will tell you how to
build python.  Look at the %build section.

--

Business Management Systems Inc.  Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flamis acribus *is" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.