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
[PATCH] 5.28.1: $^X is undefined on Linux without /proc #16808
Comments
From viy@altlinux.orgThis is a bug report for perl from viy@altlinux.org, On normal system In a chroot without /proc or just with sudo umount /proc Current implementation of $^X assumes that /proc/self/exe In that case, $^X should be PL_origargv[0]. As a result, perl tools can fail or change its behaviour. for example, now ExtUtils::MakeMaker fails without /proc: Proposed patch (tested) Inline Patchdiff --git a/caretx.c b/caretx.c
index d758f73..aa069cc 100644
--- a/caretx.c
+++ b/caretx.c
@@ -97,7 +97,15 @@ Perl_set_caret_X(pTHX) {
}
#elif defined(HAS_PROCSELFEXE)
char buf[MAXPATHLEN];
- SSize_t len = readlink(PROCSELFEXE_PATH, buf, sizeof(buf) - 1);
+ SSize_t len;
+ /* NOTE: it is possible for /proc to be unmounted
+ * or for perl to be run in a chroot environment without /proc . */
+ if (access(PROCSELFEXE_PATH, R_OK) != 0) {
+ /* Fallback */
+ sv_setpv(caret_x, PL_origargv[0]);
+ return;
+ }
+ len = readlink(PROCSELFEXE_PATH, buf, sizeof(buf) - 1);
/* NOTE: if the length returned by readlink() is sizeof(buf) - 1,
* it is impossible to know whether the result was truncated. */
---
Site configuration information for perl 5.22.3: Configured by ALT Linux Team at Wed Feb 1 13:44:57 UTC 2017. Summary of my perl5 (revision 5 version 22 subversion 3) configuration: @INC for perl 5.22.3: Environment for perl 5.22.3: |
From viy@altlinux.orgperl-5.28.1-alt-viy-caretx-chroot-support.patchdiff --git a/caretx.c b/caretx.c
index d758f73..aa069cc 100644
--- a/caretx.c
+++ b/caretx.c
@@ -97,7 +97,15 @@ Perl_set_caret_X(pTHX) {
}
#elif defined(HAS_PROCSELFEXE)
char buf[MAXPATHLEN];
- SSize_t len = readlink(PROCSELFEXE_PATH, buf, sizeof(buf) - 1);
+ SSize_t len;
+ /* NOTE: it is possible for /proc to be unmounted
+ * or for perl to be run in a chroot environment without /proc . */
+ if (access(PROCSELFEXE_PATH, R_OK) != 0) {
+ /* Fallback */
+ sv_setpv(caret_x, PL_origargv[0]);
+ return;
+ }
+ len = readlink(PROCSELFEXE_PATH, buf, sizeof(buf) - 1);
/* NOTE: if the length returned by readlink() is sizeof(buf) - 1,
* it is impossible to know whether the result was truncated. */
|
From viy@altlinux.orgIt is my first time reporting to rt.perl.org/, |
From @tonycozOn Sat, 12 Jan 2019 07:58:09 -0800, viy@altlinux.org wrote:
The code already has a fallback to: sv_setpv(caret_x, PL_origargv[0]); if the readlink() fails, which it should if /proc isn't mounted. If that's not happening can you produce a relevant strace? Thanks, |
The RT System itself - Status changed from 'new' to 'open' |
From @ilmari"Tony Cook via RT" <perlbug-followup@perl.org> writes:
It does now, but didn't in 5.28, c.f. Since this was a regression in 5.28 (introduced in - ilmari |
From @tonycozOn Mon, 14 Jan 2019 16:41:35 -0800, ilmari wrote:
Thanks, I've added it to the votes file and voted for it in 758a695. Tony |
Migrated from rt.perl.org#133765 (status was 'open')
Searchable as RT133765$
The text was updated successfully, but these errors were encountered: