Visitar URL original
ImportError: _ssl.so: undefined symbol: _PyModule_Add · Issue #108525 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20231004174028/https://github.com/python/cpython/issues/108525
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: _ssl.so: undefined symbol: _PyModule_Add #108525

Open
0x2b3bfa0 opened this issue Aug 26, 2023 · 14 comments · May be fixed by #108582
Open

ImportError: _ssl.so: undefined symbol: _PyModule_Add #108525

0x2b3bfa0 opened this issue Aug 26, 2023 · 14 comments · May be fixed by #108582
Labels
extension-modules C modules in the Modules dir topic-C-API type-bug An unexpected behavior, bug, or error

Comments

@0x2b3bfa0
Copy link

0x2b3bfa0 commented Aug 26, 2023 •

Bug report

Environment

$ uname
Linux
$ python --version{,}
Python 3.11.4 (tags/v3.11.4:d2340ef257, Aug 26 2023, 22:42:28) [GCC 12.2.0]

Description

Importing the ssl shared library from a Python 3.11.5 build from a Python 3.11.4 binary produces an ImportError due to an undefined symbol. Isn't CPython's ABI supposed to be fully compatible between patch releases?

CPython’s Application Binary Interface (ABI) is forward- and backwards-compatible across a minor release.

Example

FROM debian

RUN apt update \
 && apt install --yes build-essential git libssl-dev zlib1g-dev

RUN git clone --branch v3.11.4 https://github.com/python/cpython 3.11.4\
 && cd 3.11.4 && ./configure && make --jobs=16

RUN git clone --branch v3.11.5 https://github.com/python/cpython 3.11.5\
 && cd 3.11.5 && ./configure && make --jobs=16

RUN mv 3.11.5/build/lib.linux-x86_64-3.11/_ssl.cpython-311-x86_64-linux-gnu.so\
       3.11.4/build/lib.linux-x86_64-3.11/_ssl.cpython-311-x86_64-linux-gnu.so

RUN 3.11.4/python -m ssl

Error

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "//3.11.2/Lib/ssl.py", line 100, in <module>
    import _ssl             # if we can't import it, let the error propagate
    ^^^^^^^^^^^
ImportError: //3.11.2/build/lib.linux-x86_64-3.11/_ssl.cpython-311-x86_64-linux-gnu.so: undefined symbol: _PyModule_Add

Observations

It looks like fced79f is the breaking commit, as per git bisect results.

Linked PRs

@0x2b3bfa0 0x2b3bfa0 added the type-bug An unexpected behavior, bug, or error label Aug 26, 2023
@hansegucker
Copy link

I also observed the issue on my system.

@CorvinM
Copy link
Contributor

CorvinM commented Aug 27, 2023

Also able to reproduce between 3.11 branch and 3.11.4, looks like #106863 broke the ABI

@sunmy2019
Copy link
Member

@serhiy-storchaka as the commit author

@serhiy-storchaka
Copy link
Member

I don't think this warranty extends to the private API.

Names prefixed by an underscore, such as _Py_InternalState, are private API that can change without notice even in patch releases.

If you only use the public C API in your extension, you can expect forward- and backwards-compatibinility.

@Templarrr
Copy link

Templarrr commented Aug 31, 2023 •

I see the same error locally in poetry after my Ubuntu upgraded 3.11.? -> 3.11.5. Any advice how this can be mitigated/fixed? It doesn't look like I can downgrade local python back to 3.11.4 - deadsnakes ppa don't list 3.11.4 anymore

@LostInDarkMath
Copy link

@Templarrr I had the same issue and fixed it by updating poetry to the latest version.

@erlend-aasland
Copy link
Contributor

cc. RM @pablogsal

@Templarrr
Copy link

@LostInDarkMath thank you! Seems to be the solution

@encukou
Copy link
Member

encukou commented Aug 31, 2023

The reproducer looks contrived. In what situation would pieces of CPython get mixed up like this? Is Ubuntu's _ssl module not built together with the interpreter?

@CorvinM
Copy link
Contributor

CorvinM commented Aug 31, 2023

The reproducer looks contrived. In what situation would pieces of CPython get mixed up like this? Is Ubuntu's _ssl module not built together with the interpreter?

A faulty install or packaging script could easily cause this (but wouldn't be noticed in most cases, since they are usually ABI compatible) because the file paths are named identically (I.e., specific to 3.11, not 3.11.5).

@CorvinM
Copy link
Contributor

CorvinM commented Aug 31, 2023

In this case it looks like a problem with poetry packaging (or its pythonpath?)

@0x2b3bfa0
Copy link
Author

0x2b3bfa0 commented Aug 31, 2023 •

The original issue was also related to Python + Poetry, by the way.

@0x2b3bfa0
Copy link
Author

A faulty install or packaging script could easily cause this [...] because the file paths are named identically (i.e., specific to 3.11, not 3.11.5)

This. ☝🏼 💯

@zvolsky
Copy link

zvolsky commented Sep 14, 2023

@LostInDarkMath: I had the same issue and fixed it by updating poetry to the latest version.

My poetry --version was 1.6.1.
poetry self update exactly as other poetry commands has failed with this issue.
I decided to "update" via curl -sSL https://install.python-poetry.org | python3 -, i.e. reinstall,
the poetry --version is now again 1.6.1.
And Poetry works again.
(Debian Testing)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension-modules C modules in the Modules dir topic-C-API type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants