Skip navigation.
 
mlfile scan results in EX_BAD_ACCESS
FROM : Daniel Child
DATE : Fri Aug 31 19:38:37 2007

Hi All,

I am trying to parse a large file without approximately 300,000 lines 
of text. Judging from the console print, the method does go through 
all the records, but then the program seems to freeze with a message 
"Loading 87348  stack frames", and when I hit cancel to that alert, I 
get the EX_BAD_ACCESS error. Because of the way the debugger freezes 
(and because it would take years to load 87000 stack frames), I'm 
having a terrible time tracing the error.

Critical portions of code below. Thanks for the help.

Daniel

(in main)

   NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   DataParser *dp = [DataParser parserWithRecordDelim: @"\r"];
   NSString *path, *fullPath, *fileName;
   NSFileManager *NSFm;
   NSMutableArray *theData;
   
   fileName = @"cleaner data.txt";
   NSFm = [NSFileManager defaultManager];
   path = @"/Users/danielchild/Documents/DATA/";
   fullPath = [path stringByAppendingPathComponent: fileName];
   
   theData = [dp parseFileAtPath: fullPath];
   [pool release];
   
   return 0;

The parser is created as follows:

+ (DataParser *) parserWithRecordDelim: (NSString *) rd
{
  DataParser *dp = [[[DataParser alloc] init] autorelease];
  [dp setRecordDelim: rd];
  return dp;
}

And the parse file method is this:

- (NSMutableArray *) parseFileAtPath: (NSString *) path
{
  NSString *fileAsString, *oneRecord;
  NSMutableArray *unparsedRecords = [[[NSMutableArray alloc] init] 
autorelease];

  fileAsString = [NSString stringWithContentsOfFile: path];
  NSScanner *scanner = [NSScanner scannerWithString: fileAsString];
  while (![scanner isAtEnd])
  {
    if ([scanner scanUpToString:recordDelim intoString: &oneRecord])
    {
      [unparsedRecords addObject: oneRecord];
      printf("%s\n", [oneRecord cString]);
    }
  }
  return unparsedRecords;
}

Related mailsAuthorDate
mlfile scan results in EX_BAD_ACCESS Daniel Child Aug 31, 19:38
mlRe: file scan results in EX_BAD_ACCESS Shawn Erickson Aug 31, 19:48
mlRe: file scan results in EX_BAD_ACCESS Mike Blaguszewski Aug 31, 20:31
mlRe: file scan results in EX_BAD_ACCESS Daniel Child Sep 1, 01:06
mlRe: file scan results in EX_BAD_ACCESS Mike Blaguszewski Sep 1, 01:16
mlRe: file scan results in EX_BAD_ACCESS Daniel Child Sep 1, 04:28
mlRe: file scan results in EX_BAD_ACCESS Fritz Anderson Sep 1, 04:49
mlRe: file scan results in EX_BAD_ACCESS Shawn Erickson Sep 1, 06:11
mlRe: file scan results in EX_BAD_ACCESS Daniel Child Sep 1, 17:08
mlRe: file scan results in EX_BAD_ACCESS Daniel Child Sep 1, 17:10
mlRe: file scan results in EX_BAD_ACCESS Daniel Child Sep 1, 17:18
mlRe: file scan results in EX_BAD_ACCESS Fritz Anderson Sep 1, 17:19
mlRe: file scan results in EX_BAD_ACCESS Chris Williams Sep 1, 17:22
mlRe: file scan results in EX_BAD_ACCESS Daniel Child Sep 1, 17:28
mlRe: file scan results in EX_BAD_ACCESS Shawn Erickson Sep 1, 17:29
mlRe: file scan results in EX_BAD_ACCESS Shawn Erickson Sep 1, 17:48