FAQ
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

Search Discussions

  • Stuart D. Gathman at Nov 8, 2002 at 6:13 am

    On Thu, 07 Nov 2002 22:04:23 -0500, Neal Norwitz wrote:

    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.bmsi.com/aix/python-2.2.spec

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

    --
    Stuart D. Gathman <stuart at bmsi.com>
    Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154
    "Confutatis maledictis, flamis acribus addictis" - background song for
    a Microsoft sponsored "Where do you want to go from here?" commercial.
  • Neal Norwitz at Nov 9, 2002 at 3:11 pm

    On Fri, 08 Nov 2002 01:13:03 -0500, Stuart D. Gathman wrote:
    On Thu, 07 Nov 2002 22:04:23 -0500, Neal Norwitz wrote:

    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.
    Stuart, thanks for your reply. Actually, it is using ld_so_aix.
    I cut it out for brevity. Sorry for the confusion.

    I am using the standard make process. ./configure && make
    You can find my RPM spec file for python-2.2 at
    http://www.bmsi.com/aix/python-2.2.spec

    (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.
    I looked at your spec file. I tried setting LANG=C. It didn't help.
    I tried using xlc and -brtl -bdynamic. That also didn't help.
    I noticed that gcc was compiled with --disabled-shared. I don't know
    if that's a problem. I suspect not, since xlc also fails.

    The python.exp file appears to be created correctly. The API which
    causes the core dump is in python.exp file. This file is imported
    when trying to make the .so.

    I'm not sure how the machines are configured. So it's possible there's
    a configuration problem. I checked my limits (ulimit) and those seemed
    fine.

    Any other ideas?

    Thanks,
    Neal

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedNov 8, '02 at 3:04a
activeNov 9, '02 at 3:11p
posts3
users2
websitepython.org

2 users in discussion

Neal Norwitz: 2 posts Stuart D. Gathman: 1 post

People

Translate

site design / logo © 2022 Grokbase