Skip navigation.
 
mlCFStream CFReadStreamCopyProperty crash
FROM : Paul Collins
DATE : Wed Dec 22 21:06:46 2004

Very occasionally, my app crashes in CFReadStreamCopyProperty() after
downloading HTTP with CFStream. Am I doing something wrong? Is CFStream
reliable? The code executes in an NSTimer. In the crash log, does the
thread 2 trace indicate a mutex or lock problem?

// Finished downloading page. Called by NSTimer from CF callback.
- (void)handleStreamComplete:(NSTimer *)timer {
    NSString *contentType, *mimeType;
    NSRange r;

   // Clear ivar to timer that called this method
   streamCompleteTimer = nil;
   // Cancel timer
    [_dlTimeOuter invalidate];
   _dlTimeOuter = nil;    
    // Save the new response for authentication
    [self
setResponse:(CFHTTPMessageRef)CFReadStreamCopyProperty(_stream,
kCFStreamPropertyHTTPResponseHeader)];
    if (!_response) {
       NSLog(@"No HTTP response header found - skipping page (@%)",
[currentPage canonURL]);
       [self _closeStream];
       return;    
    }
    contentType = (NSString
*)CFHTTPMessageCopyHeaderFieldValue(_response,CFSTR("Content-Type"));
   if (contentType) {
       mimeType = contentType; // copy and keep original reference for
releasing.
       r = [mimeType rangeOfString:@";"];
       if (r.location != NSNotFound) {
           mimeType = [mimeType substringToIndex:r.location];
       }
       mimeType = [mimeType stringByTrimmingCharactersInSet:[NSCharacterSet
whitespaceAndNewlineCharacterSet]];
       CFRelease(contentType);
   } else {
       mimeType = @"<MIME type not found>";
   }
   if (!_odGotFinalUrl) {
       NSURL *finalURL = (NSURL *)CFReadStreamCopyProperty(_stream,
kCFStreamPropertyHTTPFinalURL);
       ODLog(@"Doing redirect check in _handleStreamComplete: %@", finalURL);
       if ([self checkForRedirectedURL:finalURL]) {
           [finalURL release];
           [self _closeStream];
           return;                            
       }
       [finalURL release];
   }
   // done with the stream. No more stream property getting after this.
   [self _closeStream];
.....

=========
OS Version:    10.3.4 (Build 7H63)
...
Exception:  EXC_BAD_ACCESS (0x0001)
Codes:      KERN_PROTECTION_FAILURE (0x0002) at 0x00000000

Thread 0 Crashed:
0  com.apple.CoreFoundation     0x9020209c CFReadStreamCopyProperty + 0x38
1  com.opendoor.Envision       0x0001f1b0 -[ODSlide
_handleStreamComplete] + 0x48
2  com.apple.CoreFoundation     0x901da23c _CFStreamSignalEventSynch +
0x18c
3  com.apple.CoreFoundation     0x90193d38 __CFRunLoopDoSources0 + 0x1fc
4  com.apple.CoreFoundation     0x901915f0 __CFRunLoopRun + 0x1b0
5  com.apple.CoreFoundation     0x90195f1c CFRunLoopRunSpecific + 0x148
6  com.apple.HIToolbox         0x927d62d8 RunCurrentEventLoopInMode +
0xac
7  com.apple.HIToolbox         0x927dca40 ReceiveNextEventCommon + 0x17c
8  com.apple.HIToolbox         0x927feb18
BlockUntilNextEventMatchingListInMode + 0x60
9  com.apple.AppKit             0x92dd2a34 _DPSNextEvent + 0x180
10  com.apple.AppKit             0x92de93b0 -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:] + 0x74
11  com.apple.AppKit             0x92dfd718 -[NSApplication run] + 0x21c
12  com.apple.AppKit             0x92eb9b80 NSApplicationMain + 0x1d0
13  com.opendoor.Envision       0x00009864 _start + 0x188 (crt.c:267)
14  dyld                         0x8fe1a558 _dyld_start + 0x64

Thread 1:
0  libSystem.B.dylib           0x9000b20c select + 0xc
1  com.apple.CoreFoundation     0x90196ba0 __CFSocketManager + 0x1fc
2  libSystem.B.dylib           0x900246e8 _pthread_body + 0x28

Thread 2:
0  libSystem.B.dylib           0x90016f48 semaphore_wait_signal_trap +
0x8
1  libSystem.B.dylib           0x9000e790 _pthread_cond_wait + 0x270
2  com.apple.Foundation         0x90a4bb00 -[NSConditionLock
lockWhenCondition:] + 0x44
3  com.apple.AppKit             0x92dca8dc -[NSUIHeartBeat
_heartBeatThread:] + 0x190
4  com.apple.Foundation         0x90a39b74 forkThreadForFunction + 0x6c
5  libSystem.B.dylib           0x900246e8 _pthread_body + 0x28


** Gracion Software                 http://www.gracion.com/ **
** Tel: +1 (541) 488-3488      iChat/AV/AIM: gracionsoft    **
** DigiTunnel 1.4 PPTP/VPN client for OS X                  **
** Try this--Envision: the new way to experience the web    **
** http://www.opendoor.com/envision/                        **_______________________________________________
MacOSX-dev mailing list
<email_removed>
http://www.omnigroup.com/mailman/listinfo/macosx-dev

Related mailsAuthorDate
mlCFStream CFReadStreamCopyProperty crash Paul Collins Dec 22, 21:06
mlRe: CFStream CFReadStreamCopyProperty crash Paul Collins Dec 23, 02:55