file1 has size 2147483648 (2**31)
file2 has size 2147483647 (2**31-1)
perl -we 'my $x = `cat file1`' # seg faults
perl -we 'my @x = `cat file1`' # works fine
perl -we 'my $x = `cat file2`' # works fine
perl -we 'my $x = `cat file2`; $x .= `cat file2`' # works fine
So it seems that in scalar context if the output of the command in backticks is greater than 2**31-1 then it segfaults. It seems the backticks use some buffer that has a size limit. The results were the same on 64 bit linux and cygwin.
Update: Curiously if I do:
perl -we 'my $x = `cat file2 file2`'
I get a
Out of memory in perl:util:safesysmalloc (cygwin perl 5.40)
or
Out of memory! (linux perl 5.38)
instead of a
Segmentation fault