zopencommunity / perlport

Perl programming language
Apache License 2.0
6 stars 3 forks source link

ASCII failure: perl context not propagated to child environment #16

Closed MikeFultonDev closed 2 years ago

MikeFultonDev commented 2 years ago
# 
# The following should print:
# miniperl -e 'print $ENV{TST}'
# run: foo
# which it does in EBCDIC build, but with ASCII it prints:
# miniperl -e 'print $ENV{TST}'
# run:

$|=1;
$\="\n";
my $getenv;
$getenv = "$^X -e 'print \$ENV{TST}'";
$ENV{TST}='foo';
print "$getenv";
print "run: " . `$getenv`;
khwilliamson commented 2 years ago

I did some grepping for things that might be conditional on EBCDIC when they should be conditional on os390, and vice versa. The one thing that stood out to me was in nostdio.h, it gets rid of stdio stuff except under EBCDIC. That doesn't make sense to me. The commit message isn't helpful, except the committer was working on an EBCDIC box.

If this is a dead end, bring it up on #p5p if you haven't already.

khwilliamson commented 2 years ago

And the EBCDIC box was os390.

I mean it doesn't make sense to me, because I would think that retaining or discarding stdio wouldn't be dependent on character set, but would more likely be OS dependent

MikeFultonDev commented 2 years ago

Thanks @khwilliamson ! I did discover that as well and have changed it to OEMVS. Didn't solve my problem but likely an issue - and glad to see we saw the same one so hopefully means not too many other ones out there!

MikeFultonDev commented 2 years ago

From Karl via p5p: khw: my_setenv() in util.c [3:51pm] khw: mortal_getenv in inline.h [3:52pm] khw: But you may also be running into backtick problems

MikeFultonDev commented 2 years ago

This works for both ASCII and EBCDIC:

childtest.pl

$|=1;
$\="\n";
my $getenv;
$getenv = "$^X -e 'print qq(hello)'";
print "run: " . `$getenv`;
MikeFultonDev commented 2 years ago

Also, this test works:

envtest2.pl

$|=1;
$\="\n";
my $getenv;
$getenv = "$^X -e 'print \$ENV{PATH}'";
$ENV{TST}='foo';
print "$getenv";
print "run: " . `$getenv`;

which implies that the environment variables are being passed down correctly, except for the new ones being set in the program

MikeFultonDev commented 2 years ago

problem turned out to be that the code is changing what environ points to when it is updating environment variables. This doesn't work when a child process is called with ASCII - likely because 'environ' is a macro in ASCII and LE 'probably' does not like the array of pointers being moved around. By changing the code to use 'safe' PUTENV, the code is working much better.

MikeFultonDev commented 2 years ago

Running with a debug build for ASCII, I get: Failed 38 tests out of 2478, 98.47% okay. ../cpan/ExtUtils-Constant/t/Constant.t ../cpan/File-Temp/t/object.t ../cpan/File-Temp/t/security.t ../cpan/File-Temp/t/tempfile.t ../cpan/IO-Compress/t/050interop-gzip.t ../cpan/IPC-Cmd/t/01_IPC-Cmd.t ../cpan/IPC-Cmd/t/03_run-forked.t ../cpan/Socket/t/getnameinfo.t ../cpan/Test-Harness/t/harness.t ../cpan/Test-Harness/t/source_handler.t ../cpan/libnet/t/datasend.t ../cpan/libnet/t/ftp.t ../cpan/libnet/t/nntp.t ../cpan/libnet/t/nntp_ipv6.t ../cpan/libnet/t/nntp_ssl.t ../cpan/libnet/t/pop3_ipv6.t ../cpan/libnet/t/pop3_ssl.t ../cpan/libnet/t/require.t ../cpan/libnet/t/smtp.t ../cpan/libnet/t/smtp_ipv6.t ../cpan/libnet/t/smtp_ssl.t ../cpan/podlators/t/general/basic.t ../cpan/version/t/07locale.t ../dist/ExtUtils-CBuilder/t/04-base.t ../dist/ExtUtils-ParseXS/t/002-more.t ../dist/IO/t/io_pipe.t ../dist/Net-Ping/t/520_icmp_ttl.t ../ext/POSIX/t/mb.t ../lib/ExtUtils/t/Embed.t ../lib/locale.t io/argv.t io/inplace.t io/iprefix.t io/nargv.t lib/croak.t op/fork.t op/magic.t run/switches.t ... Elapsed: 5935 sec u=49.78 s=16.59 cu=2032.48 cs=677.49 scripts=2478 tests=1200709

khwilliamson commented 2 years ago

On 12/24/21 00:09, Mike Fulton wrote:

Running with a debug build for ASCII, I get: Failed 38 tests out of 2478, 98.47% okay.

Starting to look pretty good. To prioritize the remaining ones, cpan comes last. These are highest:

io/argv.t io/inplace.t io/iprefix.t io/nargv.t lib/croak.t op/fork.t op/magic.t run/switches.t

../cpan/ExtUtils-Constant/t/Constant.t ../cpan/File-Temp/t/object.t ../cpan/File-Temp/t/security.t ../cpan/File-Temp/t/tempfile.t ../cpan/IO-Compress/t/050interop-gzip.t ../cpan/IPC-Cmd/t/01_IPC-Cmd.t ../cpan/IPC-Cmd/t/03_run-forked.t ../cpan/Socket/t/getnameinfo.t ../cpan/Test-Harness/t/harness.t ../cpan/Test-Harness/t/source_handler.t ../cpan/libnet/t/datasend.t ../cpan/libnet/t/ftp.t ../cpan/libnet/t/nntp.t ../cpan/libnet/t/nntp_ipv6.t ../cpan/libnet/t/nntp_ssl.t ../cpan/libnet/t/pop3_ipv6.t ../cpan/libnet/t/pop3_ssl.t ../cpan/libnet/t/require.t ../cpan/libnet/t/smtp.t ../cpan/libnet/t/smtp_ipv6.t ../cpan/libnet/t/smtp_ssl.t ../cpan/podlators/t/general/basic.t ../cpan/version/t/07locale.t ../dist/ExtUtils-CBuilder/t/04-base.t ../dist/ExtUtils-ParseXS/t/002-more.t ../dist/IO/t/io_pipe.t ../dist/Net-Ping/t/520_icmp_ttl.t ../ext/POSIX/t/mb.t ../lib/ExtUtils/t/Embed.t ../lib/locale.t io/argv.t io/inplace.t io/iprefix.t io/nargv.t lib/croak.t op/fork.t op/magic.t run/switches.t ... Elapsed: 5935 sec u=49.78 s=16.59 cu=2032.48 cs=677.49 scripts=2478 tests=1200709

— Reply to this email directly, view it on GitHub https://github.com/ZOSOpenTools/perlport/issues/16#issuecomment-1000690983, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2DHYPOPSJ3422BCQNUGTUSQMCXANCNFSM5J4VJNCA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

khwilliamson commented 2 years ago

And getting those to work may cause some of the other failures to fall out automatically

MikeFultonDev commented 2 years ago

Thanks Karl. I rebuilt last night without -g and got very similar results: Failed 37 tests out of 2478, 98.51% okay. ../cpan/File-Temp/t/object.t ../cpan/File-Temp/t/security.t ../cpan/File-Temp/t/tempfile.t ../cpan/IO-Compress/t/050interop-gzip.t ../cpan/IPC-Cmd/t/01_IPC-Cmd.t ../cpan/IPC-Cmd/t/03_run-forked.t ../cpan/Socket/t/getnameinfo.t ../cpan/Test-Harness/t/harness.t ../cpan/Test-Harness/t/source_handler.t ../cpan/libnet/t/datasend.t ../cpan/libnet/t/ftp.t ../cpan/libnet/t/nntp.t ../cpan/libnet/t/nntp_ipv6.t ../cpan/libnet/t/nntp_ssl.t ../cpan/libnet/t/pop3_ipv6.t ../cpan/libnet/t/pop3_ssl.t ../cpan/libnet/t/require.t ../cpan/libnet/t/smtp.t ../cpan/libnet/t/smtp_ipv6.t ../cpan/libnet/t/smtp_ssl.t ../cpan/podlators/t/general/basic.t ../cpan/version/t/07locale.t ../dist/ExtUtils-CBuilder/t/04-base.t ../dist/ExtUtils-ParseXS/t/002-more.t ../dist/IO/t/io_pipe.t ../dist/Net-Ping/t/520_icmp_ttl.t ../ext/POSIX/t/mb.t ../lib/ExtUtils/t/Embed.t ../lib/locale.t io/argv.t io/inplace.t io/iprefix.t io/nargv.t lib/croak.t op/fork.t op/magic.t run/switches.t

MikeFultonDev commented 2 years ago

lib/croak.t also fails with EBCDIC so I'll put it after the others you mention