Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: TEXTSCAN Crash

Subject: TEXTSCAN Crash

From: Andy Johnson

Date: 12 Jan, 2007 15:16:43

Message: 1 of 1

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.

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics