I think I've solved the original problem now. My user on the Linux instance had a very limited number of open file descriptors available as shown by `ulimit -n`. Increasing this limit to a higher number seems to fix it.
This also explains why the problem wasn't seen running the same program under Windows or on Linux with Valgrind, since both are different environments which presumably don't have the limitation my Linux user had.
