Page 1 of 1

Javascript corrupted with illegal characters/truncation

PostPosted: 23. Nov 2009, 02:09
by davidbjames
I am having continual Javascript problems when I browse to a web page served from my Debian 32 virtual machine which is using Apache server. I am working on Mac OSX 10.6.2 using a SMB/AFP shared folder and Virtual Box 3.0.8

The Javascript files are getting corrupted with "illegal characters" appended to them OR characters truncated off the end. At first this was happening almost randomly, but now I think it is related to file changes. For instance if I edit the files, then I get the corruption immediately. This occurs if I edit in my IDE (Zend Studio) or by ssh'ing in and editing with vim or simply using TextEdit. "touch"ing the file doesn't cause the problem. But any changes to the file does cause the problem. The corruption (garbage characters/missing characters) is only visible if I open the Javascript "file" from my browser (Firefox using Firebug console) and not in the editors themselves (although sometimes I have seen a new blank line at the end of the file).

I thought it was a browser caching issue, so I disabled cache in my browser without any luck. I have also tried other browsers and had the same issue.

I have also tried every possible combination of permissions on the shared folder.

The only solution I have found is "shutdown -r now" :(

How are the files getting corrupted? Can anyone help me?

Re: Javascript corrupted with illegal characters/truncation

PostPosted: 24. Nov 2009, 17:03
by Brainscape
I am having the exact same problem with Virtualbox 3.0.12 r54655 running Ubuntu 9.04 as a guest OS but with Windows Server 2008 Enterprise as host OS so I'm guessing it is not an OS related problem. I noticed that if I create a new file and paste the javascript content I am able to use the file but as soon as I edit an already shared file I get illegal characters/truncation.

Any help to resolve this would be greatly appreciated, really slows down my development cycles.

Re: Javascript corrupted with illegal characters/truncation

PostPosted: 25. Nov 2009, 19:04
by davidbjames
I think I figured this out! (with the help of some others)

In the VM file /etc/fstab I set the credentials to allow the host system access to the shared folder (last line of this example)

Code: Select all   Expand viewCollapse view
# /etc/fstab: static file system information.
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/hda1       /               ext3    errors=remount-ro 0       1
/dev/hda5       none            swap    sw              0       0
/dev/hdc        /media/cdrom0   udf,iso9660 user,noauto     0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto  0       0
//       /mnt/namehere cifs credentials=/etc/samba/user,defaults,uid=33,gid=33,file_mode=0777,dir_mode=0777 0 0

I also made sure that /etc/samba/user had my username and password in it.
Code: Select all   Expand viewCollapse view

Re: Javascript corrupted with illegal characters/truncation

PostPosted: 20. Jan 2010, 12:33
by dlouwers

I am using v3.1.2 (on Snow Leopard) and I am having the same issues using an Ubuntu LTS 8.04 guest OS with Apache 2. The issue is fixed when renaming the js file, refreshing the browser and giving the js file the original name again. I have to do this upon every edit of a js file otherwise it gets truncated or illegal characters get appended.

I have tried different browsers, restarting the web server on the virtual machine, using other editors, nothing helps. It makes development so slow that it's become an unusable development platform.

I will try again with on my Linux host operating system, but I have a hunch this is related to OS X looking at the previous posters.

I am using shared folders so cifs is not an option here. I am mounting the shared folder in rc.local using:
mount -t vboxsf -o rw,uid=www-data,gid=www-data <share_name> <mount_point>

Hope someone can help me with this. And if not perhaps recommend a reliable vm client I can use until this is fixed.


Dirk Louwers

Re: Javascript corrupted with illegal characters/truncation

PostPosted: 15. Feb 2010, 23:45
by costmo
I started with VBox 3.1.2 on Mac OSX host. Same problem in both Leopard and Snow Leopard. Guest: CentOS 5.4 running Apache 2.0.x. In VBox 3.1.2, I did not see this problem because a bug in VBox's native file sharing that made symbolic links not work forced us to use NFS to load the files from the MacOS host.

The symbolic link problem was fixed in 3.1.4, so we switched to using VBox file sharing. Now when updating javascript files, they seem to be cached in Apache forever and illegal characters are added to the end of the file. I thought at first that it was a browser cache issue, but switched to a browser that hadn't been used ever on the machine, and it showed the same out-of-date file with illegal characters. There were two short-term remedies:
1. Unmount and remount the file system
2. Shut down and restart apache

But that has to be done EVERY time a javascript file is updated. One long-term solution:
1. Use NFS for file sharing

This is a horribly unstable solution, especially when we want to be able to suspend and resume the guest regularly. The NFS mount seems to crash about every four or five resumptions and the only remedy it to force power-down the guest.

This is obviously a bug that people have known about and complained about for quite a while (as early as 3.0?). Does a bug report need to be filed?

Re: Javascript corrupted with illegal characters/truncation

PostPosted: 15. Mar 2010, 20:48
by mbarr
The fix is to include

EnableSendfile Off

in the httpd.conf file- it's not the JS, or css, or anything- it's just the apache server doing something Virtualbox isn't happy with. Might be nice to have a FAQ about it, though... for vboxsf, at least.