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

[3.7] segmentation-fault/core dump when try to run non-existing file specified on commandline #78964

Closed
Elias481 mannequin opened this issue Sep 24, 2018 · 16 comments
Closed
Labels
3.7 (EOL) end of life 3.8 only security fixes type-bug An unexpected behavior, bug, or error

Comments

@Elias481
Copy link
Mannequin

Elias481 mannequin commented Sep 24, 2018

BPO 34783
Nosy @vstinner, @ned-deily, @miss-islington, @tirkarthi, @Elias481
PRs
  • bpo-34783 move pymain_clear_config to directly before pymain_run_* #9522
  • [3.7] bpo-34783: Fix Py_Main() #9526
  • bpo-34783: Add test_cmd_line_script.test_nonexisting_script() #9535
  • [3.7] bpo-34783: Add test_cmd_line_script.test_nonexisting_script() (GH-9535) #9539
  • bpo-34783: Disable test_nonexisting_script for macOS framework builds #9831
  • [3.7] bpo-34783: Disable test_nonexisting_script for macOS framework builds (GH-9831) #9832
  • bpo-34783: Fix test_nonexisting_script() #9896
  • [3.7] bpo-34783: Fix test_nonexisting_script() (GH-9896) #9902
  • 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 2018-10-19.16:16:42.272>
    created_at = <Date 2018-09-24.00:00:48.526>
    labels = ['3.8', 'type-bug', '3.7']
    title = '[3.7] segmentation-fault/core dump when try to run non-existing file specified on commandline'
    updated_at = <Date 2018-10-19.16:16:42.270>
    user = 'https://github.com/Elias481'

    bugs.python.org fields:

    activity = <Date 2018-10-19.16:16:42.270>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-10-19.16:16:42.272>
    closer = 'vstinner'
    components = []
    creation = <Date 2018-09-24.00:00:48.526>
    creator = 'eohm'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 34783
    keywords = ['patch']
    message_count = 16.0
    messages = ['326191', '326192', '326197', '326210', '326211', '326224', '326238', '326245', '326249', '326251', '327620', '327621', '327622', '327793', '327799', '328051']
    nosy_count = 5.0
    nosy_names = ['vstinner', 'ned.deily', 'miss-islington', 'xtreak', 'eohm']
    pr_nums = ['9522', '9526', '9535', '9539', '9831', '9832', '9896', '9902']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue34783'
    versions = ['Python 3.7', 'Python 3.8']

    @Elias481
    Copy link
    Mannequin Author

    Elias481 mannequin commented Sep 24, 2018

    segmentation-fault/core dump when try to run non-existing file specified on commandline (pymain_run_filename)

    docker-library/python#320

    @Elias481 Elias481 mannequin added 3.7 (EOL) end of life type-bug An unexpected behavior, bug, or error labels Sep 24, 2018
    @Elias481
    Copy link
    Mannequin Author

    Elias481 mannequin commented Sep 24, 2018

    bug was probably introduced here: 1976086#diff-75445bdc3b6b3dd20b005698fa165444R2443 (but I did not test the version from before that commit)

    @Elias481
    Copy link
    Mannequin Author

    Elias481 mannequin commented Sep 24, 2018

    Did a quick cross-check with other Distro.
    With a debian stretch for example there is no SEGV and core-dump but a "(null)" output for program name instead.

    @vstinner
    Copy link
    Member

    eohm: thank you for your bug report and great job of your analysis of the root cause! Your PR works as expected, but I prefer to get the current core configuration rather than keeping our old copy longer than previously in main.c. I wrote a PR 9526 to reorganize the code to make it closer to the master branch: clarify the lifetime of the "local config" in main.c, and as soon as possible, switch to the core configuration attached to the interpreter state.

    @vstinner
    Copy link
    Member

    Note: the master branch is not affected, I already fixed the bug in master. My PR backports the fix.

    @vstinner vstinner changed the title segmentation-fault/core dump when try to run non-existing file specified on commandline [3.7] segmentation-fault/core dump when try to run non-existing file specified on commandline Sep 24, 2018
    @vstinner
    Copy link
    Member

    New changeset ddc163d by Victor Stinner in branch '3.7':
    bpo-34783: Fix Py_Main() (GH-9526)
    ddc163d

    @vstinner
    Copy link
    Member

    I wrote a non regression test: PR 9535.

    @vstinner
    Copy link
    Member

    New changeset a46467f by Victor Stinner in branch 'master':
    bpo-34783: Add test_cmd_line_script.test_nonexisting_script() (GH-9535)
    a46467f

    @miss-islington
    Copy link
    Contributor

    New changeset 7a26222 by Miss Islington (bot) in branch '3.7':
    bpo-34783: Add test_cmd_line_script.test_nonexisting_script() (GH-9535)
    7a26222

    @vstinner
    Copy link
    Member

    Thank you again eohm for your bug report and your analysis. Sadly, I chose to fix the issue differently, to reduce the maintenance burden on main.c: make the code closer to the master branch. My change is part of a long serie of changes to rework the Python initialization.

    I added non regression test to 3.7 and master as well.

    @ned-deily
    Copy link
    Member

    Re-opening. The new test_cmd_line_script fails on macOS framework builds because the test case assumes that the file name in sys.executable will appear in the error message. For macOS framework builds, sys.executable is the file name of the stub launcher and its file name bears no relationship to the file name of the actual python executable:

    $ python3.7 -c 'import sys;print(sys.executable)'
    /usr/local/bin/python3.7
    $ python3.7 -m test test_cmd_line_script
    Run tests sequentially
    0:00:00 load avg: 1.12 [1/1] test_cmd_line_script
    test test_cmd_line_script failed -- Traceback (most recent call last):
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/test/test_cmd_line_script.py", line 648, in test_nonexisting_script
        self.assertIn(program, err)
    AssertionError: 'python3.7' not found in "/Library/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python: can't open file 'nonexistingscript.py': [Errno 2] No such file or directory\n"

    test_cmd_line_script failed

    For now, I'm going to disable the test for macOS frameworks but the test should get fixed.

    @ned-deily ned-deily added the 3.8 only security fixes label Oct 13, 2018
    @ned-deily ned-deily reopened this Oct 13, 2018
    @ned-deily
    Copy link
    Member

    New changeset f6c29a6 by Ned Deily in branch 'master':
    bpo-34783: Disable test_nonexisting_script for macOS framework builds (GH-9831)
    f6c29a6

    @ned-deily
    Copy link
    Member

    New changeset 5d8ef8b by Ned Deily (Miss Islington (bot)) in branch '3.7':
    bpo-34783: Disable test_nonexisting_script for macOS framework builds (GH-9831) (GH-9832)
    5d8ef8b

    @vstinner
    Copy link
    Member

    New changeset ea75187 by Victor Stinner in branch 'master':
    bpo-34783: Fix test_nonexisting_script() (GH-9896)
    ea75187

    @miss-islington
    Copy link
    Contributor

    New changeset 350aeab by Miss Islington (bot) in branch '3.7':
    bpo-34783: Fix test_nonexisting_script() (GH-9896)
    350aeab

    @vstinner
    Copy link
    Member

    The issue should be fixed now, I close it again.

    @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.7 (EOL) end of life 3.8 only security fixes type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants