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: [3.7] segmentation-fault/core dump when try to run non-existing file specified on commandline
Type: behavior Stage: resolved
Components: Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: eohm, miss-islington, ned.deily, vstinner, xtreak
Priority: normal Keywords: patch

Created on 2018-09-24 00:00 by eohm, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 9522 closed eohm, 2018-09-24 00:35
PR 9526 merged vstinner, 2018-09-24 09:40
PR 9535 merged vstinner, 2018-09-24 14:22
PR 9539 merged miss-islington, 2018-09-24 15:06
PR 9831 merged ned.deily, 2018-10-13 03:32
PR 9832 merged miss-islington, 2018-10-13 03:54
PR 9896 merged vstinner, 2018-10-15 21:12
PR 9902 merged miss-islington, 2018-10-15 21:51
Messages (16)
msg326191 - (view) Author: (eohm) * Date: 2018-09-24 00:00
segmentation-fault/core dump when try to run non-existing file specified on commandline (pymain_run_filename)

https://github.com/docker-library/python/issues/320
msg326192 - (view) Author: (eohm) * Date: 2018-09-24 00:02
bug was probably introduced here: python/cpython@1976086#diff-75445bdc3b6b3dd20b005698fa165444R2443 (but I did not test the version from before that commit)
msg326197 - (view) Author: (eohm) * Date: 2018-09-24 00:37
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.
msg326210 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-09-24 09:41
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.
msg326211 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-09-24 09:43
Note: the master branch is not affected, I already fixed the bug in master. My PR backports the fix.
msg326224 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-09-24 12:03
New changeset ddc163df25191af5bf8000091dbf8f6500b1d7c9 by Victor Stinner in branch '3.7':
bpo-34783: Fix Py_Main() (GH-9526)
https://github.com/python/cpython/commit/ddc163df25191af5bf8000091dbf8f6500b1d7c9
msg326238 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-09-24 14:22
I wrote a non regression test: PR 9535.
msg326245 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-09-24 15:06
New changeset a46467ff198c42c8f34768c7be4b4562f6f44736 by Victor Stinner in branch 'master':
bpo-34783: Add test_cmd_line_script.test_nonexisting_script() (GH-9535)
https://github.com/python/cpython/commit/a46467ff198c42c8f34768c7be4b4562f6f44736
msg326249 - (view) Author: miss-islington (miss-islington) Date: 2018-09-24 15:28
New changeset 7a26222d7caa507fc46119ba9246f163502eb1fd by Miss Islington (bot) in branch '3.7':
bpo-34783: Add test_cmd_line_script.test_nonexisting_script() (GH-9535)
https://github.com/python/cpython/commit/7a26222d7caa507fc46119ba9246f163502eb1fd
msg326251 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-09-24 15:34
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.
msg327620 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2018-10-13 03:53
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.
msg327621 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2018-10-13 03:54
New changeset f6c29a65e2a6da5c0014c868cf963c975b74e72b by Ned Deily in branch 'master':
bpo-34783:  Disable test_nonexisting_script for macOS framework builds (GH-9831)
https://github.com/python/cpython/commit/f6c29a65e2a6da5c0014c868cf963c975b74e72b
msg327622 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2018-10-13 04:07
New changeset 5d8ef8bc3f7307cd15f9d82ad4846e82b498ae88 by Ned Deily (Miss Islington (bot)) in branch '3.7':
bpo-34783:  Disable test_nonexisting_script for macOS framework builds (GH-9831) (GH-9832)
https://github.com/python/cpython/commit/5d8ef8bc3f7307cd15f9d82ad4846e82b498ae88
msg327793 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-10-15 21:50
New changeset ea75187c68b374bb839f1172f310b206044bc3e5 by Victor Stinner in branch 'master':
bpo-34783: Fix test_nonexisting_script() (GH-9896)
https://github.com/python/cpython/commit/ea75187c68b374bb839f1172f310b206044bc3e5
msg327799 - (view) Author: miss-islington (miss-islington) Date: 2018-10-15 22:30
New changeset 350aeab8127da551fcd0090230575b7aabff03c9 by Miss Islington (bot) in branch '3.7':
bpo-34783: Fix test_nonexisting_script() (GH-9896)
https://github.com/python/cpython/commit/350aeab8127da551fcd0090230575b7aabff03c9
msg328051 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-10-19 16:16
The issue should be fixed now, I close it again.
History
Date User Action Args
2022-04-11 14:59:06adminsetgithub: 78964
2018-10-19 16:16:42vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg328051

stage: patch review -> resolved
2018-10-15 22:30:09miss-islingtonsetmessages: + msg327799
2018-10-15 21:51:08miss-islingtonsetpull_requests: + pull_request9264
2018-10-15 21:50:59vstinnersetmessages: + msg327793
2018-10-15 21:12:03vstinnersetpull_requests: + pull_request9258
2018-10-13 04:07:05ned.deilysetmessages: + msg327622
2018-10-13 03:54:41miss-islingtonsetpull_requests: + pull_request9206
2018-10-13 03:54:24ned.deilysetmessages: + msg327621
2018-10-13 03:53:41ned.deilysetstatus: closed -> open

versions: + Python 3.8
nosy: + ned.deily

messages: + msg327620
resolution: fixed -> (no value)
stage: resolved -> patch review
2018-10-13 03:32:50ned.deilysetpull_requests: + pull_request9205
2018-09-24 15:34:52vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg326251

stage: patch review -> resolved
2018-09-24 15:28:31miss-islingtonsetnosy: + miss-islington
messages: + msg326249
2018-09-24 15:06:51miss-islingtonsetpull_requests: + pull_request8941
2018-09-24 15:06:34vstinnersetmessages: + msg326245
2018-09-24 14:22:37vstinnersetmessages: + msg326238
2018-09-24 14:22:16vstinnersetpull_requests: + pull_request8938
2018-09-24 12:03:04vstinnersetmessages: + msg326224
2018-09-24 09:43:25vstinnersetmessages: + msg326211
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
2018-09-24 09:41:21vstinnersetmessages: + msg326210
2018-09-24 09:40:26vstinnersetpull_requests: + pull_request8931
2018-09-24 04:35:38ned.deilysetnosy: + vstinner
2018-09-24 02:40:18xtreaksetnosy: + xtreak
2018-09-24 00:37:40eohmsetmessages: + msg326197
2018-09-24 00:35:17eohmsetkeywords: + patch
stage: patch review
pull_requests: + pull_request8926
2018-09-24 00:02:42eohmsetmessages: + msg326192
2018-09-24 00:00:48eohmcreate