[MacRuby] #540: segfault with NSURLDownload with GC on
#540: segfault with NSURLDownload with GC on -------------------------------------+-------------------------------------- Reporter: mattaimonetti@… | Owner: mattaimonetti@… Type: defect | Status: new Priority: major | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: -------------------------------------+-------------------------------------- Script: https://gist.github.com/96954a4e59f1293977c0 Backtrace: {{{ Application Specific Information: objc_msgSend() selector name: _downloadActive objc[74889]: garbage collection is ON Thread 0 Crashed: Dispatch queue: com.apple.main-thread 0 libobjc.A.dylib 0x00007fff8821011c objc_msgSend + 40 1 com.apple.Foundation 0x00007fff84db156d _NSURLDownloadDidReceiveData + 45 2 com.apple.CFNetwork 0x00007fff8143b50f URLDownload::sendClientDidReceiveData(long, long, long) + 83 3 com.apple.CFNetwork 0x00007fff8143cd9c ___asyncWrite_block_invoke_4 + 121 4 com.apple.CoreFoundation 0x00007fff8060c1b9 __CFRunLoopDoBlocks + 297 5 com.apple.CoreFoundation 0x00007fff805cece6 __CFRunLoopRun + 3046 6 com.apple.CoreFoundation 0x00007fff805cdc2f CFRunLoopRunSpecific + 575 7 com.apple.Foundation 0x00007fff84c94a24 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 270 8 com.apple.Foundation 0x00007fff84ce048a -[NSRunLoop(NSRunLoop) runUntilDate:] + 78 9 ??? 0x00000001011005fc 0 + 4312794620 Thread 1: Dispatch queue: com.apple.libdispatch-manager 0 libSystem.B.dylib 0x00007fff8650cbba kevent + 10 1 libSystem.B.dylib 0x00007fff8650ea85 _dispatch_mgr_invoke + 154 2 libSystem.B.dylib 0x00007fff8650e75c _dispatch_queue_invoke + 185 3 libSystem.B.dylib 0x00007fff8650e286 _dispatch_worker_thread2 + 244 4 libSystem.B.dylib 0x00007fff8650dbb8 _pthread_wqthread + 353 5 libSystem.B.dylib 0x00007fff8650da55 start_wqthread + 13 Thread 2: 0 libSystem.B.dylib 0x00007fff8650d9da __workq_kernreturn + 10 1 libSystem.B.dylib 0x00007fff8650ddec _pthread_wqthread + 917 2 libSystem.B.dylib 0x00007fff8650da55 start_wqthread + 13 Thread 3: 0 libSystem.B.dylib 0x00007fff8650d9da __workq_kernreturn + 10 1 libSystem.B.dylib 0x00007fff8650ddec _pthread_wqthread + 917 2 libSystem.B.dylib 0x00007fff8650da55 start_wqthread + 13 Thread 4: 0 libSystem.B.dylib 0x00007fff864f3e3a mach_msg_trap + 10 1 libSystem.B.dylib 0x00007fff864f44ad mach_msg + 59 2 com.apple.CoreFoundation 0x00007fff805ce7a2 __CFRunLoopRun + 1698 3 com.apple.CoreFoundation 0x00007fff805cdc2f CFRunLoopRunSpecific + 575 4 com.apple.Foundation 0x00007fff84cd94cf +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] + 297 5 com.apple.Foundation 0x00007fff84c59e99 __NSThread__main__ + 1429 6 libSystem.B.dylib 0x00007fff8652cf8e _pthread_start + 331 7 libSystem.B.dylib 0x00007fff8652ce41 thread_start + 13 Thread 5: 0 libSystem.B.dylib 0x00007fff8650d9da __workq_kernreturn + 10 1 libSystem.B.dylib 0x00007fff8650ddec _pthread_wqthread + 917 2 libSystem.B.dylib 0x00007fff8650da55 start_wqthread + 13 Thread 6: 0 libSystem.B.dylib 0x00007fff865379e2 select$DARWIN_EXTSN + 10 1 com.apple.CoreFoundation 0x00007fff805f0242 __CFSocketManager + 818 2 libSystem.B.dylib 0x00007fff8652cf8e _pthread_start + 331 3 libSystem.B.dylib 0x00007fff8652ce41 thread_start + 13 }}} works fine with GC_DISABLE=1 --- TODO: Rewrite the script in pure objc, compile with -fobjc-gc and see if it's a MacRuby bug or a Cocoa bug. -- Ticket URL: <http://www.macruby.org/trac/ticket/540> MacRuby <http://macruby.org/>
#540: segfault with NSURLDownload with GC on -------------------------------------+-------------------------------------- Reporter: mattaimonetti@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: NSURLDownload, Cocoa -------------------------------------+-------------------------------------- Changes (by mattaimonetti@…): * keywords: => NSURLDownload, Cocoa * owner: mattaimonetti@… => lsansonetti@… Old description:
Script: https://gist.github.com/96954a4e59f1293977c0
Backtrace: {{{ Application Specific Information: objc_msgSend() selector name: _downloadActive objc[74889]: garbage collection is ON
Thread 0 Crashed: Dispatch queue: com.apple.main-thread 0 libobjc.A.dylib 0x00007fff8821011c objc_msgSend + 40 1 com.apple.Foundation 0x00007fff84db156d _NSURLDownloadDidReceiveData + 45 2 com.apple.CFNetwork 0x00007fff8143b50f URLDownload::sendClientDidReceiveData(long, long, long) + 83 3 com.apple.CFNetwork 0x00007fff8143cd9c ___asyncWrite_block_invoke_4 + 121 4 com.apple.CoreFoundation 0x00007fff8060c1b9 __CFRunLoopDoBlocks + 297 5 com.apple.CoreFoundation 0x00007fff805cece6 __CFRunLoopRun + 3046 6 com.apple.CoreFoundation 0x00007fff805cdc2f CFRunLoopRunSpecific + 575 7 com.apple.Foundation 0x00007fff84c94a24 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 270 8 com.apple.Foundation 0x00007fff84ce048a -[NSRunLoop(NSRunLoop) runUntilDate:] + 78 9 ??? 0x00000001011005fc 0 + 4312794620
Thread 1: Dispatch queue: com.apple.libdispatch-manager 0 libSystem.B.dylib 0x00007fff8650cbba kevent + 10 1 libSystem.B.dylib 0x00007fff8650ea85 _dispatch_mgr_invoke + 154 2 libSystem.B.dylib 0x00007fff8650e75c _dispatch_queue_invoke + 185 3 libSystem.B.dylib 0x00007fff8650e286 _dispatch_worker_thread2 + 244 4 libSystem.B.dylib 0x00007fff8650dbb8 _pthread_wqthread + 353 5 libSystem.B.dylib 0x00007fff8650da55 start_wqthread + 13
Thread 2: 0 libSystem.B.dylib 0x00007fff8650d9da __workq_kernreturn + 10 1 libSystem.B.dylib 0x00007fff8650ddec _pthread_wqthread + 917 2 libSystem.B.dylib 0x00007fff8650da55 start_wqthread + 13
Thread 3: 0 libSystem.B.dylib 0x00007fff8650d9da __workq_kernreturn + 10 1 libSystem.B.dylib 0x00007fff8650ddec _pthread_wqthread + 917 2 libSystem.B.dylib 0x00007fff8650da55 start_wqthread + 13
Thread 4: 0 libSystem.B.dylib 0x00007fff864f3e3a mach_msg_trap + 10 1 libSystem.B.dylib 0x00007fff864f44ad mach_msg + 59 2 com.apple.CoreFoundation 0x00007fff805ce7a2 __CFRunLoopRun + 1698 3 com.apple.CoreFoundation 0x00007fff805cdc2f CFRunLoopRunSpecific + 575 4 com.apple.Foundation 0x00007fff84cd94cf +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] + 297 5 com.apple.Foundation 0x00007fff84c59e99 __NSThread__main__ + 1429 6 libSystem.B.dylib 0x00007fff8652cf8e _pthread_start + 331 7 libSystem.B.dylib 0x00007fff8652ce41 thread_start + 13
Thread 5: 0 libSystem.B.dylib 0x00007fff8650d9da __workq_kernreturn + 10 1 libSystem.B.dylib 0x00007fff8650ddec _pthread_wqthread + 917 2 libSystem.B.dylib 0x00007fff8650da55 start_wqthread + 13
Thread 6: 0 libSystem.B.dylib 0x00007fff865379e2 select$DARWIN_EXTSN + 10 1 com.apple.CoreFoundation 0x00007fff805f0242 __CFSocketManager + 818 2 libSystem.B.dylib 0x00007fff8652cf8e _pthread_start + 331 3 libSystem.B.dylib 0x00007fff8652ce41 thread_start + 13 }}}
works fine with GC_DISABLE=1
---
TODO: Rewrite the script in pure objc, compile with -fobjc-gc and see if it's a MacRuby bug or a Cocoa bug.
New description: Script: https://gist.github.com/96954a4e59f1293977c0 Backtrace: {{{ Application Specific Information: objc_msgSend() selector name: _downloadActive objc[74889]: garbage collection is ON Thread 0 Crashed: Dispatch queue: com.apple.main-thread 0 libobjc.A.dylib 0x00007fff8821011c objc_msgSend + 40 1 com.apple.Foundation 0x00007fff84db156d _NSURLDownloadDidReceiveData + 45 2 com.apple.CFNetwork 0x00007fff8143b50f URLDownload::sendClientDidReceiveData(long, long, long) + 83 3 com.apple.CFNetwork 0x00007fff8143cd9c ___asyncWrite_block_invoke_4 + 121 4 com.apple.CoreFoundation 0x00007fff8060c1b9 __CFRunLoopDoBlocks + 297 5 com.apple.CoreFoundation 0x00007fff805cece6 __CFRunLoopRun + 3046 6 com.apple.CoreFoundation 0x00007fff805cdc2f CFRunLoopRunSpecific + 575 7 com.apple.Foundation 0x00007fff84c94a24 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 270 8 com.apple.Foundation 0x00007fff84ce048a -[NSRunLoop(NSRunLoop) runUntilDate:] + 78 9 ??? 0x00000001011005fc 0 + 4312794620 Thread 1: Dispatch queue: com.apple.libdispatch-manager 0 libSystem.B.dylib 0x00007fff8650cbba kevent + 10 1 libSystem.B.dylib 0x00007fff8650ea85 _dispatch_mgr_invoke + 154 2 libSystem.B.dylib 0x00007fff8650e75c _dispatch_queue_invoke + 185 3 libSystem.B.dylib 0x00007fff8650e286 _dispatch_worker_thread2 + 244 4 libSystem.B.dylib 0x00007fff8650dbb8 _pthread_wqthread + 353 5 libSystem.B.dylib 0x00007fff8650da55 start_wqthread + 13 Thread 2: 0 libSystem.B.dylib 0x00007fff8650d9da __workq_kernreturn + 10 1 libSystem.B.dylib 0x00007fff8650ddec _pthread_wqthread + 917 2 libSystem.B.dylib 0x00007fff8650da55 start_wqthread + 13 Thread 3: 0 libSystem.B.dylib 0x00007fff8650d9da __workq_kernreturn + 10 1 libSystem.B.dylib 0x00007fff8650ddec _pthread_wqthread + 917 2 libSystem.B.dylib 0x00007fff8650da55 start_wqthread + 13 Thread 4: 0 libSystem.B.dylib 0x00007fff864f3e3a mach_msg_trap + 10 1 libSystem.B.dylib 0x00007fff864f44ad mach_msg + 59 2 com.apple.CoreFoundation 0x00007fff805ce7a2 __CFRunLoopRun + 1698 3 com.apple.CoreFoundation 0x00007fff805cdc2f CFRunLoopRunSpecific + 575 4 com.apple.Foundation 0x00007fff84cd94cf +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] + 297 5 com.apple.Foundation 0x00007fff84c59e99 __NSThread__main__ + 1429 6 libSystem.B.dylib 0x00007fff8652cf8e _pthread_start + 331 7 libSystem.B.dylib 0x00007fff8652ce41 thread_start + 13 Thread 5: 0 libSystem.B.dylib 0x00007fff8650d9da __workq_kernreturn + 10 1 libSystem.B.dylib 0x00007fff8650ddec _pthread_wqthread + 917 2 libSystem.B.dylib 0x00007fff8650da55 start_wqthread + 13 Thread 6: 0 libSystem.B.dylib 0x00007fff865379e2 select$DARWIN_EXTSN + 10 1 com.apple.CoreFoundation 0x00007fff805f0242 __CFSocketManager + 818 2 libSystem.B.dylib 0x00007fff8652cf8e _pthread_start + 331 3 libSystem.B.dylib 0x00007fff8652ce41 thread_start + 13 }}} works fine with GC_DISABLE=1 --- TODO: Rewrite the script in pure objc, compile with -fobjc-gc and see if it's a MacRuby bug or a Cocoa bug. -- Comment: ported to obj-c and everything works fine even with the GC on: {{{ #import <Foundation/Foundation.h> @interface Test : NSObject @end @implementation Test -(void)startDownload{ NSString *url_string = @"http://macruby.icoretech.org/latest"; NSURL *url = [NSURL URLWithString: url_string]; NSURLRequest *req = [NSURLRequest requestWithURL: url]; [[NSURLDownload alloc] initWithRequest: req delegate: self]; } - (void)downloadDidFinish:(NSURLDownload *)download { NSLog(@"Download finished!"); exit(0); } @end int main (void) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; [[Test alloc] startDownload]; NSLog(@"Hello, Laurent"); [[NSRunLoop currentRunLoop] runUntilDate: [NSDate distantFuture]]; [pool drain]; return 0; } }}} Note that the MacRuby script works fine on small files but seems to fail on big files (at least the latest pkg) -- Ticket URL: <http://www.macruby.org/trac/ticket/540#comment:1> MacRuby <http://macruby.org/>
#540: segfault with NSURLDownload with GC on -------------------------------------+-------------------------------------- Reporter: mattaimonetti@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: NSURLDownload, Cocoa -------------------------------------+-------------------------------------- Comment(by chapbr@…): One potential issue with the macruby example code is passing 'self' as the delegate to the NSURLDownload instance. Maybe it's supposed to work, but since the delegate methods are defined in the top level namespace, I wasn't sure what the self instance actually refers to (?): {{{ $ macruby -e 'p self' # => main $ macruby -e 'p self.class' #=> TopLevel }}} I modified the gist example code to move the delegate methods inside of a Test class and then passed an instance of that class as the delegate to NSURLDownload. The new version no longer crashes during download: https://gist.github.com/d5d8f8a5208fa4a4d94c -- Ticket URL: <http://www.macruby.org/trac/ticket/540#comment:2> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby