Is dataWithContentsOfURL: thread-safe?
Is dataWithContentsOfURL: thread-safe?
- Subject: Is dataWithContentsOfURL: thread-safe?
- From: George Ma <email@hidden>
- Date: Mon, 21 Jan 2002 15:16:18 -0800
Hi all,
I am using NSData dataWithContentsOfURL: in a multithreaded app as such:
NSData *aData = [NSData dataWithContentsOfURL: instanceURL];
The app crashes randomly with this:
md_rand.c:303: failed assertion `md_c[1] == md_count[1]'
So my question is, is dataWithContentsOfURL: thread-safe? If not, what's
the recommended way of retrieving an HTML page in a multi-threaded app?
Thanks in advance,
George Ma
Here is the backtrace:
(gdb) bt
#0 0x7000098c in read ()
#1 0x701dd880 in fdRead ()
#2 0x701e4658 in socketRead ()
#3 0x701b6afc in CFReadStreamRead ()
#4 0x75188198 in _CFURLWriteDataAndPropertiesToResource ()
#5 0x75181794 in _CFHTTPMessageCopySerializedMessage ()
#6 0x701de0bc in fdWrite ()
#7 0x701b6afc in CFReadStreamRead ()
#8 0x75180ecc in _mh_dylib_header ()
#9 0x701b6afc in CFReadStreamRead ()
#10 0x7087d208 in -[NSHTTPURLHandle loadInForeground] ()
#11 0x708afd28 in -[NSURLHandle resourceData] ()
#12 0x708aec28 in -[NSURL resourceDataUsingCache:] ()
#13 0x7082dfd4 in -[NSData initWithContentsOfURL:] ()
#14 0x708511a4 in +[NSData dataWithContentsOfURL:] ()
#15 0x0000662c in -[WatcherWindowController
_fetchInstanceStatsFor:runningAt:] (self=0x25d14e0, _cmd=0xa338,
theInstance=0x210bf90, instanceURL=0x33d5f20) at
WatcherWindowController.m:152/Users/local/Projects/Current/Watcher/
#16 0x00007760 in -[WatcherWindowController _retrieveStats:]
(self=0x25d14e0, _cmd=0xa328, unused=0x0) at
WatcherWindowController.m:293/Users/local/Projects/Current/Watcher/
#17 0x70842358 in forkThreadForFunction ()
#18 0x7002054c in _pthread_body ()