|
Certain use of textscan (or textread) causes my system to crash.
Granted it only happens when I write clumsy code (without error
checking), but it sure seems strange anyway. Here's the code:
fid = fopen('\\server\directory\file.ext');
[Answer1, Answer2] = textscan(fid,'%f %f %*f');
fclose(fid);
The root cause of the problem is the fact that I don't have a
connection to the server described in the fopen(), so the fopen fails
and I continue on like an idiot and try to do the textscan. I know,
that's wrong, but here's what's funny.
1. Typing these commands in the command line causes an expected
error and no other problems. Running the exact same code in an .m
file causes an out-of-memory error. In my original code (which has
much more code than shown here) it causes my whole machine to bog
down and die, and the out of memory error never shows up in MATLAB.
I have to reboot.
2. The filename must specify a server-looking path (with the \\).
Any old non-existent file will not cause the problem.
3. You must have the '%*f' at the end of the parse string. Putting
it between the two %f fields instead of at the end will not cause a
problem. Not having a %*f will not cause the problem.
4. You must have two valid fields you're attempting to parse. If
you have only one %f it will not cause a problem.
I've reproduced it on two different machines with the same results.
MATLAB R2006b, Windows XP SP2.
So is this a bug? I know how to fix my code (by putting error
checking in after the fopen) but it sure took a long time to figure
out what was going on since I had to reboot every time I tried
something. I just thought I'd let people know.
|