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

Method Py_FrozenMain missing in libpython3.9 #86757

Closed
chba mannequin opened this issue Dec 7, 2020 · 15 comments
Closed

Method Py_FrozenMain missing in libpython3.9 #86757

chba mannequin opened this issue Dec 7, 2020 · 15 comments
Labels
3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir

Comments

@chba
Copy link
Mannequin

chba mannequin commented Dec 7, 2020

BPO 42591
Nosy @vstinner, @encukou, @pablogsal, @miss-islington
PRs
  • bpo-42591: Export missing Py_FrozenMain() symbol #23730
  • [3.9] bpo-42591: Export missing Py_FrozenMain() symbol (GH-23730) #23734
  • bpo-43795: Remove Py_FrozenMain from the Limited API & Stable ABI  #26241
  • [3.10] bpo-43795: Remove Py_FrozenMain from the Limited API & Stable ABI (GH-26241) #26353
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-12-14.23:33:30.176>
    created_at = <Date 2020-12-07.16:00:33.880>
    labels = ['library', '3.9', '3.10']
    title = 'Method Py_FrozenMain missing in libpython3.9'
    updated_at = <Date 2021-05-25.11:59:25.858>
    user = 'https://bugs.python.org/chba'

    bugs.python.org fields:

    activity = <Date 2021-05-25.11:59:25.858>
    actor = 'pablogsal'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-12-14.23:33:30.176>
    closer = 'vstinner'
    components = ['Library (Lib)']
    creation = <Date 2020-12-07.16:00:33.880>
    creator = 'chba'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 42591
    keywords = ['patch']
    message_count = 15.0
    messages = ['382651', '382817', '382818', '382819', '382829', '382835', '382836', '383021', '383022', '383121', '383123', '383154', '383156', '393878', '394333']
    nosy_count = 5.0
    nosy_names = ['vstinner', 'petr.viktorin', 'chba', 'pablogsal', 'miss-islington']
    pr_nums = ['23730', '23734', '26241', '26353']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue42591'
    versions = ['Python 3.9', 'Python 3.10']

    @chba
    Copy link
    Mannequin Author

    chba mannequin commented Dec 7, 2020

    In Python 3.9.0 and 3.9.1rc1 (Packages from Ubuntu Devel Branch or Fedora) the Method
    int Py_FrozenMain(int, char**)
    is missing in libpython3.9.so

    Thus, when trying the provided freeze example via
    freeze.py hello.py & make
    one gets the linker error
    /usr/bin/ld: frozen.o: in function main': frozen/frozen.c:681: undefined reference to Py_FrozenMain' .

    In previous Python 3.8.x the bug does not show.

    Thanks,
    Chris

    @chba chba mannequin added topic-C-API 3.9 only security fixes stdlib Python modules in the Lib dir and removed topic-C-API labels Dec 7, 2020
    @chba
    Copy link
    Mannequin Author

    chba mannequin commented Dec 10, 2020

    The same under Python 3.9.1 (Package from Debian bullseye/testing). As the method Py_FrozenMain is contained in the source code, maybe ist has something to do with the build process, a change in makefile? As far as I can see, the builder of the distribution packages call the makefile as provided.

    Chris

    @chba
    Copy link
    Mannequin Author

    chba mannequin commented Dec 10, 2020

    The file containing the source code is Python/frozenmain.c .

    @vstinner
    Copy link
    Member

    I wrote PR 23730 to fix the issue. Would it be possible for you to test it?

    Since Python 3.9, symbols which are not explicitly exported are no longer exported. Python now uses -fvisibility=hidden.

    @chba
    Copy link
    Mannequin Author

    chba mannequin commented Dec 10, 2020

    Dear Victor,

    a simple test with the tools/freeze/hello.py example was successfull with your patch and the newest cpython from github.

    1. git clone https://github.com/python/cpython.git
    2. Applied a patch of your pull request
      3
      . configure, make, amke install to xxx
    3. freeze.py wants wants this for a very long time:
      ln -s /usr/local/lib/python3.10/config-3.10-x86_64-linux-gnu
      /usr/local/lib/python3.10/config-3.10
    4. python3 cpython/Tools/freeze.py -o frozen hello.py
    5. cd frozen; make; ./hello
      Helo world...

    Thanks again,
    Chris

    @vstinner
    Copy link
    Member

    New changeset b5c7b38 by Victor Stinner in branch 'master':
    bpo-42591: Export missing Py_FrozenMain() symbol (GH-23730)
    b5c7b38

    @vstinner
    Copy link
    Member

    a simple test with the tools/freeze/hello.py example was successfull with your patch and the newest cpython from github.

    Oh great, thanks for your quick feedback! I applied your PR to master and I will backport it to 3.9.

    @vstinner
    Copy link
    Member

    New changeset 6b2ed38 by Victor Stinner in branch '3.9':
    bpo-42591: Export missing Py_FrozenMain() symbol (GH-23730) (GH-23734)
    6b2ed38

    @vstinner
    Copy link
    Member

    Thanks Christian Bachmaier for the bug report, it's now fixed.

    @vstinner vstinner added the 3.10 only security fixes label Dec 14, 2020
    @vstinner vstinner added the 3.10 only security fixes label Dec 14, 2020
    @vstinner
    Copy link
    Member

    Christian Bachmaier:

    Thus, when trying the provided freeze example via
    freeze.py hello.py & make

    Do you mean freeze.py from Tools/freeze/freeze.py? This tool seems to be broken for 4 years, since Python 3.6: bpo-42613.

    1. freeze.py wants wants this for a very long time:
      ln -s /usr/local/lib/python3.10/config-3.10-x86_64-linux-gnu
      /usr/local/lib/python3.10/config-3.10

    Oh, you fixed manually freeze.py?

    @chba
    Copy link
    Mannequin Author

    chba mannequin commented Dec 16, 2020

    Do you mean freeze.py from Tools/freeze/freeze.py?

    Yes, unfortunately I have to keep a large old system running and there are only few options left. It is a University learning system, where students upload program code and then a huge amount of automtic quality checks are executed within a sandbox. The grading is done in a half automtic way. A real alternative is not existing, we tried hard to find one...

    This tool seems to
    be broken for 4 years, since Python 3.6: bpo-42613.
    4. freeze.py wants wants this for a very long time:
    ln -s /usr/local/lib/python3.10/config-3.10-x86_64-linux-gnu
    /usr/local/lib/python3.10/config-3.10

    The symlink does the trick. So it may be easy for you to fix that, so it does operate out of the box again.

    @vstinner
    Copy link
    Member

    Christian Bachmaier:

    The symlink does the trick. So it may be easy for you to fix that, so it does operate out of the box again.

    I pushed a fix in bpo-42613. It would be great if you could test it.

    See my manual test: https://bugs.python.org/issue42613#msg383153

    If you can test it, I can backport the fix to stable branches.

    @chba
    Copy link
    Mannequin Author

    chba mannequin commented Dec 16, 2020

    Vistor Stinner:

    If you can test it, I can backport the fix to stable branches.

    Seems to work like a charm. Basically I used the same testing setup as previously on Dec 10th under Debian testing/bullseye without step 2, as master already contains your fix.

    Victor, many thanks again, you are great!

    @encukou
    Copy link
    Member

    encukou commented May 18, 2021

    Is this function actually usable in Windows? ISTM that you need to define three more functions, PyWinFreeze_ExeInit, PyWinFreeze_ExeTerm and PyInitFrozenExtensions.

    Was adding this undocumented function to the Windows stable ABI deliberate? I see no discussion about that.

    @pablogsal
    Copy link
    Member

    New changeset 68b9c20 by Miss Islington (bot) in branch '3.10':
    bpo-43795: Remove Py_FrozenMain from the Limited API & Stable ABI (GH-26241) (GH-26353)
    68b9c20

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants