VMware Communities
beatrohrer
Contributor
Contributor
Jump to solution

Bug Report: Strange behaviour with Mac folder sharing & PHP require (VMware 8)

I'm using VMware Fusion 8.0.0 (2985594) on Mac OS Yosemite (10.10.5 (14F27)) and have a Linux VM with Debian Wheezy (3.2.0-4-amd64) and PHP (5.4.41-0+deb7u1).

After I've upgraded from VMware Fusion 7 to WMware Fusion 8, the Typo3 (an open source CMS) on my development machine started throwing PHP syntax errors when reading its cache files. As I've been investigating the problem I've found that the behaviour is reproducible but only when the files are written to the folder shared between the the Host system and the VM.

When I'm requiring a PHP file of a certain size and a certain file name, PHP appears to continue reading over the end of the file into the middle of arbitrary other files. This leads mostly to PHP syntax errors – but depending on the file name they differ, e.g.:

PHP Parse error:  syntax error, unexpected '' in require284.php on line 93
PHP Parse error:  syntax error, unexpected '' in require107.php on line 88
^[[APHP Parse error:  syntax error, unexpected 'p' in require472.php on line 88
PHP Parse error:  syntax error, unexpected end of file in require884.php on line 88
PHP Parse error:  syntax error, unexpected 'u' in require185.php on line 89

All of these errors are generated by requiring the same content with different file names. If I'm requiring the same file with the same name, the PHP error is also the same.

Steps to reproduce

I've written a PHP script which tries different file names for a given text until it crashes. Store this file in the shared folder and execute it with php -f. As you can see, all of the content of the file is commented out, so it shouldn't affect anything.

<?php
$content = <<<'EOT'
<?php
/*njsRtWyvEHREGDwjZEIuuwOCJidhxoMo
lsdTFPMPhCnHYdjylYmAlJtOrNQRZRzFDQsX
QAYugjeSRojQLImGMsGzvsNxSdbvIUZbHvVuXfDTJqyXxjbiNoMgiQGVlREJPPacTIbn
emIhHyATFwSAHnoTRVtUppVVRoWHDAjMvkoADVBCTJFNT
aCUTsQsZbIhyaQoSCWcpuhgPcoWBD
bXzAuYZueusNALsxIYTpkaHGGwmLkdkEPsQRSyPojOhCTUksYnAdlr
rDfHEzqctbHpFBQkUTOWgYsYKwBzguuNxktJDitUkSDLABoDjYlrQzmtBxRU
TRZqbDEgTEGqpFAXbCADhmwVltDJGqvsasypalIThuzA
VDJ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VLjluFnDlFLHWseOeJXSFjrfBUXLcIoITqozfHolhIdCmHUsKKYtnng
FrlAfGIMXlQRYfsaigOJABjLRknqdIbZlZVcLOqjKYmPcjrHH
SLrsFrNInZMHVeWJHPKwGFKNapGNMgXFqtPOdB
KExsWUQXnoORsjShtiRRCTYSKwSAhQjgZbzwRHTsiWGIukdOD
PJKBKqUvyQvWlsrJENAeNLiVTDapsYAnqQwYFuskUVaWHtditUJpiFVsJwKytWu
aihAvXNVkxTqixFtPumJDocWAmvocxDHZtUzCcEoFHdwFzclKlAdfLOuhZgqZDTptmXii
DgYmqpKdlbCtenKLhAVrWmJuDofoWpCPHWYdtjXZiYajKuFh
GGyFSgSVkGRwVakkZafdGvOMHalwDyeOZY
oFrLUGOVbaHClgsfLepNpHagKdPzLGnilQUAbPyiSrVcIiJaChvlYOIIWWPRPl

*/
EOT;

for($i = 0; $i < 1000; $i++) {
     // generate a random number
     $rnd = rand(0, 1000);
     $filename = 'require' . $rnd . '.php';
     echo "Try no. $i, filename $filename\n";
     // write the content to $filename
     file_put_contents($filename, $content);
     // require the same file
     require($filename);
}

I've written another script to generate the generate the combination of text and filename which causes the problem:

<?php

// the decimal ASCII code of all upper and lower case chars
$ascii_alpha_chars= array_merge(range(65, 90), range(97, 122));

// how many tries
$count = 500;

$out= '';
for($i = 0; $i < $count; $i++) {
     // generate a random number of files
     $lines = rand(70, 90);
     $out ='';
     for($j = 0; $j < $lines; $j++) {
          // ...and a random number of chars on each line
          $rand = rand(30, 70);
          $out .= get_random_chars($rand) . "\n";
     }
     write_and_require($out);
//     echo "$i\n";
}

function write_and_require($out) {
     // write the content to a file, require it, and delete it
     $sourceCode= "<?php\n/*n$out\n*/\n";
     for($i = 0; $i < 50; $i++) {
          $rnd = rand(0, 1000);
          $filename = 'require' . $rnd . '.php';
//          echo "$filename\n";
          file_put_contents($filename, $sourceCode);
          require_once($filename);
          unlink($filename);
     }
}

function get_random_chars($n) {
     global $ascii_alpha_chars;
     $out = '';
     for($i = 0; $i < $n; $i++) {
          // add a random char
          $out .= chr($ascii_alpha_chars[array_rand($ascii_alpha_chars)]);
     }
     return $out;
}

As this problem only occurs since upgrading to VMware 8 and only when the script is running in the shared folders, I strongly suspect it to be a problem within the VMware stack.

Can anyone elso reproduce this behaviour?

0 Kudos
1 Solution

Accepted Solutions
steve_goddard
VMware Employee
VMware Employee
Jump to solution

‌hi there

if you were using the HGFS kernel client from an open-vm-tools then yes there are bugs because the version that was shipped with that was broken and not tested. People didn't listen to my complaints on this.

Current recommended approach is to always use the VMware tools installation for the Shared Folders feature.

open-vm-tools are being used to install the user mode tools only. We are trying to make all features available with these including a FUSE based file sharing client. Version 10 of the open-vm-tools will have this.

Stick with VMware tools install for now for the file sharing.

thanks for al l your great information and debugging this issue.

Steve

Thanks. Steve

View solution in original post

0 Kudos
4 Replies
steve_goddard
VMware Employee
VMware Employee
Jump to solution

‌hi there,

I am the developer for the file sharing feature.

Thanks for the very helpful and detailed report.

I will file a bug and try to reproduce the bug with your scripts.

I will let you know what I find and if I need anything else (unlikely given all the details).

Steve

Thanks. Steve
0 Kudos
beatrohrer
Contributor
Contributor
Jump to solution

Hi Steve,

Thank you for the fast reply.

I really hope you'll be able to reproduce the issue; to me it looks quite esoteric: you need the right file name, the right file size (small files never cause any problems) and the correct bytes in it (just replacing one character with another can make the problem disappear)…

I could provide you with strace or ltrace logs of the execution of the PHP script or a copy of the VM if needed.

Thanks

Beat

0 Kudos
beatrohrer
Contributor
Contributor
Jump to solution

Hi Steve,

I've got an update: I've downgraded to VMware Fusion 7 in order to be able to work again. On VMware Fusion 7 I've run my first script with the fixed content and the variable file name and it encountered no error but, but with my second script (that one that brute forces content & file name) I could reproduce the same errors I've had with VMware Fusion 8! Then I've uninstalled the "open-vm-tools" and installed the "VMware Tools" via the Menu and run my test scripts again – and the errors are gone.

So I've reinstalled VMware 8 Fusion, used "VMware Tools" from the menu instead, installed it, run my scripts and everything was fine.

I conclude: the problem is with open-vm-tools.

Beat

0 Kudos
steve_goddard
VMware Employee
VMware Employee
Jump to solution

‌hi there

if you were using the HGFS kernel client from an open-vm-tools then yes there are bugs because the version that was shipped with that was broken and not tested. People didn't listen to my complaints on this.

Current recommended approach is to always use the VMware tools installation for the Shared Folders feature.

open-vm-tools are being used to install the user mode tools only. We are trying to make all features available with these including a FUSE based file sharing client. Version 10 of the open-vm-tools will have this.

Stick with VMware tools install for now for the file sharing.

thanks for al l your great information and debugging this issue.

Steve

Thanks. Steve
0 Kudos