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

Interpreter doesn't start when dynamic loading is disabled #68957

Closed
JeffreyArmstrong mannequin opened this issue Aug 1, 2015 · 15 comments
Closed

Interpreter doesn't start when dynamic loading is disabled #68957

JeffreyArmstrong mannequin opened this issue Aug 1, 2015 · 15 comments
Assignees
Labels
build The build process and cross-build release-blocker

Comments

@JeffreyArmstrong
Copy link
Mannequin

JeffreyArmstrong mannequin commented Aug 1, 2015

BPO 24769
Nosy @brettcannon, @ncoghlan, @larryhastings, @rbtcollins, @termim, @encukou, @ericsnowcurrently
Files
  • issue24769.patch
  • 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 = 'https://github.com/larryhastings'
    closed_at = <Date 2015-08-25.02:55:23.405>
    created_at = <Date 2015-08-01.03:17:42.505>
    labels = ['build', 'release-blocker']
    title = "Interpreter doesn't start when dynamic loading is disabled"
    updated_at = <Date 2015-08-25.21:35:24.183>
    user = 'https://bugs.python.org/JeffreyArmstrong'

    bugs.python.org fields:

    activity = <Date 2015-08-25.21:35:24.183>
    actor = 'python-dev'
    assignee = 'larry'
    closed = True
    closed_date = <Date 2015-08-25.02:55:23.405>
    closer = 'larry'
    components = ['Build']
    creation = <Date 2015-08-01.03:17:42.505>
    creator = 'Jeffrey.Armstrong'
    dependencies = []
    files = ['40156']
    hgrepos = []
    issue_num = 24769
    keywords = ['patch']
    message_count = 15.0
    messages = ['247797', '248033', '248359', '248370', '248374', '248403', '248754', '248776', '249085', '249101', '249109', '249122', '249123', '249159', '249162']
    nosy_count = 9.0
    nosy_names = ['brett.cannon', 'ncoghlan', 'larry', 'rbcollins', 'termim', 'petr.viktorin', 'python-dev', 'eric.snow', 'Jeffrey.Armstrong']
    pr_nums = []
    priority = 'release blocker'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'compile error'
    url = 'https://bugs.python.org/issue24769'
    versions = ['Python 3.5', 'Python 3.6']

    @JeffreyArmstrong
    Copy link
    Mannequin Author

    JeffreyArmstrong mannequin commented Aug 1, 2015

    When attempting to build Python without dynamic loading (HAVE_DYNAMIC_LOADING is not defined), the module "_imp" will not have the function "exec_dynamic." However, Lib/bootstrap.py seems to assume that "_imp.exec_dynamic" exists, causing the error:

    ----

    ./python -E -S -m sysconfig --generate-posix-vars ;\
    if test $? -ne 0 ; then \
    	echo "generate-posix-vars failed" ; \
    	rm -f ./pybuilddir.txt ; \
    	exit 1 ; \
    fi
    Traceback (most recent call last):
      File "<frozen importlib._bootstrap>", line 1134, in _install
      File "<frozen importlib._bootstrap>", line 1114, in _setup
      File "<frozen importlib._bootstrap>", line 1082, in _builtin_from_name
      File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
      File "<frozen importlib._bootstrap>", line 748, in exec_module
    AttributeError: module '_imp' has no attribute 'exec_dynamic'
    Fatal Python error: Py_Initialize: importlib install failed

    Current thread 0x00000000 (most recent call first):
    ABNORMAL TERMINATION
    generate-posix-vars failed
    ----

    when trying to build. This error means that Python 3.5 will not be able to build in a purely static (no dynamic loading whatsoever) form.

    This error was encountered in Python 3.5b4.

    @JeffreyArmstrong JeffreyArmstrong mannequin added build The build process and cross-build labels Aug 1, 2015
    @ncoghlan
    Copy link
    Contributor

    ncoghlan commented Aug 5, 2015

    This is an interesting find - thanks.

    Adding Larry as 3.5 release manager to the cc here, as I think the right fix actually involves an API adjustment inside _imp.

    One of the consequences of PEP-489 (multi-phase initialisation) was that builtin imports and extension module imports now share a lot more code, and that includes the fact that while we have both _imp.create_builtin and _imp.create_dynamic, they currently share a module level exec implementation in _imp.exec_dynamic.

    However, the definition and implementation of _imp.exec_dynamic is still behind the same preprocessor guard as _imp.create_dynamic, hence the error reported here.

    As far as a fix goes, rather than defining _imp.exec_dynamic unconditionally, my inclination is to say that merging the Python level APIs in addition to the underyling C level implementation represents a design mistake when we implemented the PEP, and there should be a separate _imp.exec_builtin function.

    The fact that _imp.exec_dynamic just called _imp.exec_builtin internally would then be a pure CPython implementation detail, rather than something importlib specifically depended on.

    @encukou
    Copy link
    Member

    encukou commented Aug 10, 2015

    Apologies for the delay; I was on vacation.

    This was indeed a mistake in PEP-489 implementation. I agree with Nick on the solution.
    Here is a patch that adds exec_builtin, with implementation shared with exec_dynamic.

    @ericsnowcurrently
    Copy link
    Member

    Looks fine to me. Nick had suggested calling exec_builtin from exec_dynamic (to the same effect as your patch), but I don't consider that much of an issue. :)

    @encukou
    Copy link
    Member

    encukou commented Aug 10, 2015

    Right. I think a common helper is cleaner than calling a clinic-generated wrapper.

    @larryhastings
    Copy link
    Contributor

    Uh, Nick? You didn't add me to this bug.

    @rbtcollins
    Copy link
    Member

    Patch looks good to me too. I think this needs to be put forward as a PR to bitbucket right? It looks Release Critical to me.

    @brettcannon
    Copy link
    Member

    It's ultimately Larry's call, but I think it should go into 3.5.0.

    @larryhastings
    Copy link
    Contributor

    Yes, I'll accept this into 3.5.0, please send a pull request.

    @larryhastings
    Copy link
    Contributor

    I wanted to get this in to Python 3.5.0rc2, so I checked it in myself. Petr, I gave you credit in the checkin comment and Misc/NEWS. Hope that's okay!

    @ncoghlan
    Copy link
    Contributor

    Thanks Larry! Sorry I didn't get to this as soon as I got back from the US.

    Will you add it to 3.5.1 and 3.6.0, or would you prefer I take care of that?

    @JeffreyArmstrong
    Copy link
    Mannequin Author

    JeffreyArmstrong mannequin commented Aug 25, 2015

    I pulled the 3.5 branch a few minutes ago, and the patch isn't present. Has it not been pushed to hg.python.org?

    @larryhastings
    Copy link
    Contributor

    That's correct, it's just in 3.5.0 at the moment.

    @larryhastings
    Copy link
    Contributor

    I have merged it forward into 3.5.1 and 3.6.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 25, 2015

    New changeset 931593401e3e by Larry Hastings in branch '3.5':
    Issue bpo-24769: Interpreter now starts properly when dynamic loading
    https://hg.python.org/cpython/rev/931593401e3e

    @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
    build The build process and cross-build release-blocker
    Projects
    None yet
    Development

    No branches or pull requests

    6 participants