Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"IOError: [Errno 71] Protocol error" when reading a file with python in a virtualbox debian machine

Tags:

I try to open and read a file in Python 2.7.3 which is running in a virtual machine:

Host: Ubuntu 14.04 LTS

Guest: Debian Wheezy 7.5

VM-Software: VirtualBox V4.3.30

In the Python console inside the VM, I enter the following:

>>> f = open("Testing/results.txt", "w+")
>>> f.read()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IOError: [Errno 71] Protocol error

The file exists and is located in a shared folder. If I try to do the same on a file which is located on the file system of the VM, it works fine. Also opening the file with mode "r+" or "a+", it works but it doesn't get truncated. Truncating the file manually after opening in read mode is working and currently, I use that as a workaround. But maybe anybody here knows, why this error occurs?

like image 636
MacDschie Avatar asked Jul 31 '15 23:07

MacDschie


1 Answers

The most probable cause of this error is a bug in the VirtualBox Linux Guest Additions, more specifically, one of its device drivers vboxguest (which communicates with the host) and vboxsf (which provides shared folder services on the guest on top of vboxguest).

Background: When using the Linux read(2) system call on VirtualBox shared files, specific conditions make the VirtualBox driver(s) fail with error 71 (EPROTO) – Protocol error (see tickets below). The error originates in the Linux kernel space and propagates via the C library to applications (see errno(3)). In this case, the application happens to be the Python interpreter.

There is nothing wrong with the Python code or file permissions. The code just performs a legitimate sequence of operations which triggers the error.

Relevant VirtualBox tickets:

  • #2584 (vboxfs EPROTO error during file read)
  • #8463 (Protocol error when using strip over shared folders.)

According to ticket #8463, this bug (or a related one) was fixed in VirtualBox Linux Guest Additions 5.1.14 / 5.0.32 on January 17, 2017.

like image 190
Oliver O. Avatar answered Sep 21 '22 17:09

Oliver O.