sporadic crash - help requested in finding cause
sporadic crash - help requested in finding cause
- Subject: sporadic crash - help requested in finding cause
- From: Donald Hall <email@hidden>
- Date: Mon, 30 Jun 2003 00:37:24 -0600
Hello all,
I am hoping someone who has far more experience with Cocoa than me
can help with a sporadic crash I am having. Here is what the crash
log says:
Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_INVALID_ADDRESS (0x0001) at 0x03d4f91b
Thread 0 Crashed:
#0 0x9068ba50 in objc_msgSend
#1 0x0000b5e0 in +[FSNode rootItem]
#2 0x0000ba90 in -[OutlineViewDataSource outlineView:child:ofItem:]
... etc
Here is the code for rootItem:
--------------------------------------------------------------------------------
@implementation FSNode
static FSNode *rootItem = nil;
static NSString *baseFolder = nil; // folder whose contents are to be
displayed, use @"/" for full file system
static NSDate *baseFolderModDate; // keep track, to note changes
#define IsALeafNode ((id)-1)
- (id)initWithPath:(NSString *)path parent:(FSNode *)obj {
if (self = [super init]) {
relativePath = [[path lastPathComponent] copy];
parent = obj;
}
return self;
}
+ (FSNode *)rootItem {
NSDate *modDate;
// see if the default folder has changed to another folder, or
has been modified
NSString *defaultFolder = [[NSUserDefaults standardUserDefaults]
objectForKey:AMDefaultFolderKey];
NSDictionary *fattrs; // need file attributes to get modification
date of folder
fattrs = [[NSFileManager defaultManager]
fileAttributesAtPath:defaultFolder traverseLink:YES];
if (fattrs) { // there is a folder at this path
modDate = [fattrs objectForKey:NSFileModificationDate];
}
// if a new folder, or old folder modified, must reestablish node hierarchy
if (![baseFolder isEqualToString:defaultFolder] ||
![baseFolderModDate isEqualToDate:modDate] ) {
baseFolder = defaultFolder;
baseFolderModDate = [modDate copy];
[rootItem autorelease];
rootItem = [[FSNode alloc] initWithPath:baseFolder parent:nil];
}
//NSLog(@"FSNode root item is %@, baseFolder is %@", rootItem, baseFolder);
return rootItem;
}
--------------------------------------------------------------------------------
Note that fattrs should always be non-nil because defaultFolder
always exists. (I suppose it would be smart to define modDate outside
the 'if' just in case.)
The sporadic nature of the crash makes if very hard to figure out
where the problem is. When it does occur, it seems to happen when the
window containing the OutlineView for which the FSNode class
represents the data is brought the front. (The contents of
'baseFolder' are being displayed as a hierarchy of files and folders.)
Can anyone see any obvious problems or suggest how to track this
down.? I assume the 'objc_msgSend' call in the crash log can only be
from the few obvious places in the 'rootItem' method?
Thanks in advance,
Don
--
Donald S. Hall, Ph.D.
Apps & More Software Design, Inc.
email@hidden
http://www.appsandmore.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.