You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
alpine: core dumped when try to run non-existing file #320
I haven't managed to figure out anything more, though. There were a bunch of changes in that file for Python 3.7 and have been a bunch since 3.7.0 was released.
@JayH5 found reason.
Investigated history and found the bug was introduced here: python/cpython@1976086#diff-75445bdc3b6b3dd20b005698fa165444R2443
So it should be totally unrelated to Alpine... But on for example the stretch-slim Distro a "(null)" is returned for program name. Anyway it's a bug that has to be fixed and not "just an alpine issue"...
So, I think this makes sense. It's the case that fprintf comes from libc -- if pymain->config.program is NULL, then it appears GLIBC handles that gracefully and %ls will give (null), where musl (arguably reasonably) segfaults when asked to format NULL as a string. See https://stackoverflow.com/a/11589479/433558 for another discussion of this same issue (where it's noted that passing NULL to %s is "undefined" according to the ANSI spec).
Has this been raised on the Python bug tracker? I imagine the patch could be as trivial as a ternary to swap out a NULL value for some other meaningful string, but I have to admit I don't understand the purpose of pymain->config.program here (given that the filename in question appears later in the error message already).
@tianon yes it has been raise and fixed. (see reference in timeline)
I made a POC change (simply move the code that sets the config to NULL to later position). Sure it would have been possible to just swap out the NULL value, but as it alsways would show null here the better solution would have been to just remove the config.program from output.
The config.program containst the executable name for the interpreter (so python, python3.7 or whatever the binary was called). It's more nice to keep the program name in output. Even more with python as You are quite likely to have different python executables running.
Anyway stinner merged some further changes he did to this section in the master/3.8 branch to 3.7 branch and so the problem is now fixed with not a simple change but with an already existing solution.
I already tested the patched version and it puts out program name correctly and does not dump core.
Nice! So this fix will be in the next 3.7 release?
(I'm closing this issue since the issue itself is very minor, the image's behavior is an accurate representation of Python's own behavior, and it appears it'll likely be fixed in the next 3.7 release. 👍)
Activity
wglambert commentedon Jul 30, 2018
This is the only similar issue #177
The issue is alpine specific, perhaps it's an anomaly with musl.
tianon commentedon Jul 30, 2018
I'm not sure what's causing it, but for someone who wants to dig into what's going on here, the end of an
strace python ssssss.pyhas the following:(Doesn't appear to contain any obvious clues.)
JayH5 commentedon Aug 6, 2018
I've done a bit of digging. It seems that
pymain->config.programis null here for some reason:https://github.com/python/cpython/blob/1bf9cc509326bc42cd8cb1650eb9bf64550d817e/Modules/main.c#L1461-L1462
I haven't managed to figure out anything more, though. There were a bunch of changes in that file for Python 3.7 and have been a bunch since 3.7.0 was released.
Rloota commentedon Aug 27, 2018
Confirming issue. Attempting to execute any non-existing file results in a segfault on fresh Alpine Python 3.6 docker image.
Elias481 commentedon Sep 23, 2018
@JayH5 found reason.
Investigated history and found the bug was introduced here: python/cpython@1976086#diff-75445bdc3b6b3dd20b005698fa165444R2443
So it should be totally unrelated to Alpine... But on for example the stretch-slim Distro a "(null)" is returned for program name. Anyway it's a bug that has to be fixed and not "just an alpine issue"...
Bug is still present in current 3.7 branch..
tianon commentedon Sep 24, 2018
So, I think this makes sense. It's the case that
fprintfcomes from libc -- ifpymain->config.programisNULL, then it appears GLIBC handles that gracefully and%lswill give(null), where musl (arguably reasonably) segfaults when asked to formatNULLas a string. See https://stackoverflow.com/a/11589479/433558 for another discussion of this same issue (where it's noted that passingNULLto%sis "undefined" according to the ANSI spec).Has this been raised on the Python bug tracker? I imagine the patch could be as trivial as a ternary to swap out a
NULLvalue for some other meaningful string, but I have to admit I don't understand the purpose ofpymain->config.programhere (given that the filename in question appears later in the error message already).Elias481 commentedon Sep 26, 2018
@tianon yes it has been raise and fixed. (see reference in timeline)
I made a POC change (simply move the code that sets the config to NULL to later position). Sure it would have been possible to just swap out the NULL value, but as it alsways would show null here the better solution would have been to just remove the config.program from output.
The config.program containst the executable name for the interpreter (so python, python3.7 or whatever the binary was called). It's more nice to keep the program name in output. Even more with python as You are quite likely to have different python executables running.
Anyway stinner merged some further changes he did to this section in the master/3.8 branch to 3.7 branch and so the problem is now fixed with not a simple change but with an already existing solution.
I already tested the patched version and it puts out program name correctly and does not dump core.
tianon commentedon Oct 17, 2018
Nice! So this fix will be in the next 3.7 release?
(I'm closing this issue since the issue itself is very minor, the image's behavior is an accurate representation of Python's own behavior, and it appears it'll likely be fixed in the next 3.7 release. 👍)