Perl calls using system abruptly start failing

Viewed 212

This week one of my standard perl [Strawberry perl 5, version 32, subversion 1 (v5.32.1) built for MSWin32-x64-multi-thread] scripts started failing. I tracked it down to a failing backtick operation.

Investigation showed that all the system-type calls, backtick, qx, pipe open, are failing. I tried building a debug version of perl, and even that fails, as the build process uses miniperl, which has the same problem.

..\miniperl.exe -I..\lib ..\make_ext.pl "MAKE=nmake -nologo" --dir=..\cpan --dir=..\dist --dir=..\ext --nonxs
Can't spawn "cmd.exe": No such file or directory at ..\make_ext.pl line 580.
Can't spawn "cmd.exe": No such file or directory at ..\make_ext.pl line 582.
Unsuccessful make(dist/if): code=65280 at ..\make_ext.pl line 584.

I tried defining PERL5SHELL (full path to cmd, pwsh in place of cmd), turning off malware protection, everything I could think of reverting.

So, the actual question: Does anyone have a suggestion for how I can track this down? It was working on Thursday, and there have been no system updates since then [OS version 10.0.22000].

3 Answers

I ran into the same problem starting a couple of weeks ago. I use ActiveState perl, so I tried installing Strawberry perl, but got the same problem w/ Strawberry. I also saw the zero length files getting created. This is happening on multiple machines. One is Winver 1909 and the other is 21H2. A workaround is to use the full path for the program you want to run.
You can also insert the full path to cmd.exe ahead of the program. Try this:

$temp = `$ENV{COMSPEC} /c date /T`;
print "\$temp = $temp";

I've been assuming this was due to a W10 security update, but I really do not know the cause. I am going to write a sub called Backticks() that I could use like this:

print Backticks('date /T');

sub Backticks would return $ENV{COMSPEC} /c @_. This is a hack, but at this point I do not know what else to do.

Using the Malwarebytes beta (4.5.10.200) version fixes this problem for me.

I ran into the same problem starting about 10 days ago. I thought it had to do with path, but it appears ok. Problem is on 2 machines: Win10 and Win11. The Win11 PC I just purchased a couple of days ago, install strawberry and tested. Same error when I call system(..). Short term solution I found is to copy cmd.exe from c:\windows\system32 into the directory where the script is running. Not a good solution, but it gets me through the day. I suspect it's some security update made in windows in the past couple of weeks.

Update 6/15/22: I can confirm that Malwarebytes beta (4.5.10.200) version fixes this. However, I had this problem on my Win11 PC before installing Malwarebytes. Maybe it's a problem with Windows Security?

Related