This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: AIX: Python: RuntimeError "invalid slot offset when importing a module" in _ssl module
Type: compile error Stage:
Components: Build Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: David.Edelsohn, dellair.jie, vstinner
Priority: normal Keywords:

Created on 2013-11-20 09:45 by dellair.jie, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (8)
msg203465 - (view) Author: dellair jie (dellair.jie) Date: 2013-11-20 09:45
Dear all,

I am getting above error when trying to import ssl module. In fact, the error showed up during the build and _ssl module was added to the failed module list. However, the compilation and link went well. 

There was no error on compilation and link phases, only some warnings. However, during Python build, there is an import phase right after the link, which shows the same error as stated.
building '_ssl' extension 
xlc_r -DNDEBUG -O -IInclude -I. -I/usr/local/include -c /aix/Modules/_ssl.c -o build/temp.aix-6.1-3.3/aix/Modules/_ssl.o
 "/aix/Modules/_ssl.c", line 262.17: 1506-196 (W) Initialization between types "void*" and "struct _object*(*)(struct {...}*)" is not allowed.
 /aix/Modules/ld_so_aix xlc_r -bI:/aix/Modules/python.exp build/temp.aix-6.1-3.3/aix/Modules/_ssl.o -L/usr/local/lib -lssl -lcrypto -o build/lib.aix-6.1-3.3/_ssl.so
 ld: 0711-224 WARNING: Duplicate symbol: .bcopy 
ld: 0711-224 WARNING: Duplicate symbol: .memcpy 
ld: 0711-224 WARNING: Duplicate symbol: .memmove 
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information. 
*** WARNING: importing extension "_ssl" failed with build/lib.aix-6.1-3.3/_ssl.so: <class 'RuntimeError'>: invalid slot offset: <traceback object at 0x3017e9e0>

I went through google to search for similar issue/solution however no succeeds. Hence I suppose it is a bug.

Env: Python: 3.3.2 
OpenSSL: 0.9.8y (also tried 0.9.7) 
OS: AIX 6.1 (also tried on HPUX_1131_IA, same problem)
msg203561 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-11-21 02:26
This warning is interesting:

 "/aix/Modules/_ssl.c", line 262.17: 1506-196 (W) Initialization between types "void*" and "struct _object*(*)(struct {...}*)" is not allowed.

It looks like the following line:

static PyType_Slot sslerror_type_slots[] = {
    {Py_tp_base, NULL},  /* Filled out in module init as it's not a constant */ <===== HERE =====
    {Py_tp_doc, SSLError_doc},
    {Py_tp_str, SSLError_str},
    {0, 0},
};

NULL is replaced in PyInit__ssl():

    sslerror_type_slots[0].pfunc = PyExc_OSError;
msg203568 - (view) Author: David Edelsohn (David.Edelsohn) * Date: 2013-11-21 02:43
Can you try compiling the module using xlc_r without -O ? One possible guess is XLC optimizations can speculate through NULL pointers because AIX maps address 0 as valid in processes. I don't know why Python is finding an invalid value in the structure.
msg203604 - (view) Author: dellair jie (dellair.jie) Date: 2013-11-21 10:28
Still seeing the same error without optimization, the build log from HPUX 11.31IA is also attached for reference (maybe irrelevance though ^^):

AIX 6.1:
cc -qlanglvl=extc89 -O0 -IInclude -I. -I/usr/local/include -c /aix/Modules/_ssl.c -o build/temp.aix-6.1-3.3-pydebug/aix/Modules/_ssl.o
"/aix/Modules/_ssl.c", line 262.17: 1506-196 (W) Initialization between types "void*" and "struct _object*(*)(struct {...}*)" is not allowed.
/aix/Modules/ld_so_aix cc -qlanglvl=extc89 -bI:/aix/Modules/python.exp build/temp.aix-6.1-3.3-pydebug/aix/Modules/_ssl.o -L/usr/local/lib -lssl -lcrypto -o build/lib.aix-6.1-3.3-pydebug/_ssl.so
ld: 0711-224 WARNING: Duplicate symbol: .bcopy
ld: 0711-224 WARNING: Duplicate symbol: .memcpy
ld: 0711-224 WARNING: Duplicate symbol: .memmove
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
*** WARNING: importing extension "_ssl" failed with build/lib.aix-6.1-3.3-pydebug/_ssl.so: <class 'RuntimeError'>: invalid slot offset: <traceback object at 0x30366038>

HPUX11.31:
building '_ssl' extension
cc +z -O0 -IInclude -I. -I/hpux/Include -I/hpux -c /hpux/Modules/_ssl.c -o build/temp.hp-ux-B.11.31-ia64-3.3-pydebug/hpux/Modules/_ssl.o
"/hpux/Modules/_ssl.c", line 383: warning #4232-D:
          conversion from "PyObject *" to a more strictly aligned type
          "PySocketSockObject *" may cause misaligned access
                    = (PySocketSockObject *) PyWeakref_GetObject(obj->Socket);
                      ^

"/hpux/Modules/_ssl.c", line 499: warning #4232-D:
          conversion from "PyObject *" to a more strictly aligned type
          "PySocketSockObject *" may cause misaligned access
        = (PySocketSockObject *) PyWeakref_GetObject(self->Socket);
          ^

"/hpux/Modules/_ssl.c", line 1220: warning #2111-D:
          statement is unreachable
      if (!_PyIsSelectable_fd(s->sock_fd))
      ^

"/hpux/Modules/_ssl.c", line 1253: warning #4232-D:
          conversion from "PyObject *" to a more strictly aligned type
          "PySocketSockObject *" may cause misaligned access
        = (PySocketSockObject *) PyWeakref_GetObject(self->Socket);
          ^

"/hpux/Modules/_ssl.c", line 1363: warning #4232-D:
          conversion from "PyObject *" to a more strictly aligned type
          "PySocketSockObject *" may cause misaligned access
        = (PySocketSockObject *) PyWeakref_GetObject(self->Socket);
          ^

"/hpux/Modules/_ssl.c", line 1484: warning #4232-D:
          conversion from "PyObject *" to a more strictly aligned type
          "PySocketSockObject *" may cause misaligned access
        = (PySocketSockObject *) PyWeakref_GetObject(self->Socket);
          ^

ld -b build/temp.hp-ux-B.11.31-ia64-3.3-pydebug/hpux/Modules/_ssl.o -L/usr/local/lib -lssl -lcrypto -o build/lib.hp-ux-B.11.31-ia64-3.3-pydebug/_ssl.so
*** WARNING: importing extension "_ssl" failed with <class 'RuntimeError'>: invalid slot offset

Please let me know if further information is required.

Br,
msg203762 - (view) Author: dellair jie (dellair.jie) Date: 2013-11-22 14:21
Folks,

Is there a patch to apply on this, I tried to search online, found one similar post but was solved until the poster switched to another version of xlc. Do we need to use another compiler(I will have to build though)?

Please don't hesitate to contact me if further information is needed for analysis.

Thanks,
msg204271 - (view) Author: dellair jie (dellair.jie) Date: 2013-11-24 22:04
It would be appreciated if someone could shed some lights on how to rebuild a single module (ssl) from source code package and import it to python. 

Thanks in advance!
msg204608 - (view) Author: dellair jie (dellair.jie) Date: 2013-11-27 19:08
I have rebuilt Python 3.3.2 with GCC 4.4.0 on AIX6.1.
There was no warning. But, still seeing the same import offset runtime error:

gcc -pthread -DNDEBUG -g -fwrapv -O0 -Wall -Wstrict-prototypes -IInclude -I. -Iopenssl/include -Iopenssl/include -IPython/Python-3.3.2-aix/Include -IPython/Python-3.3.2-aix -c Python/Python-3.3.2-aix/Modules/_ssl.c -o build/temp.aix-6.1-3.3Python/Python-3.3.2-aix/Modules/_ssl.o

Python/Python-3.3.2-aix/Modules/ld_so_aix gcc -pthread -bI:Python/Python-3.3.2-aix/Modules/python.exp build/temp.aix-6.1-3.3Python/Python-3.3.2-aix/Modules/_ssl.o -Lopenssl/lib -Lopenssl/lib -lssl -lcrypto -o build/lib.aix-6.1-3.3/_ssl.so

*** WARNING: importing extension "_ssl" failed with build/lib.aix-6.1-3.3/_ssl.so: <class 'RuntimeError'>: invalid slot offset: <traceback object at 0x30378788>
msg205845 - (view) Author: dellair jie (dellair.jie) Date: 2013-12-10 19:03
Folks,

I am closing this bug as it seems to be fixed with a with a redownload of original package.

Thanks for sharing the ideas.

Br,
Li
History
Date User Action Args
2022-04-11 14:57:53adminsetgithub: 63860
2013-12-10 19:03:09dellair.jiesetstatus: open -> closed
resolution: fixed
messages: + msg205845
2013-11-27 19:08:27dellair.jiesetmessages: + msg204608
2013-11-24 22:04:51dellair.jiesetmessages: + msg204271
2013-11-22 14:21:08dellair.jiesetmessages: + msg203762
2013-11-21 10:28:16dellair.jiesetmessages: + msg203604
2013-11-21 02:43:46David.Edelsohnsetmessages: + msg203568
2013-11-21 02:26:45vstinnersettitle: Python: RuntimeError: invalid slot offset when importing a module -> AIX: Python: RuntimeError "invalid slot offset when importing a module" in _ssl module
2013-11-21 02:26:28vstinnersetnosy: + vstinner
messages: + msg203561
2013-11-21 02:23:34vstinnersetnosy: + David.Edelsohn
2013-11-20 09:45:07dellair.jiecreate