alexcrichton / AudioStreamer

A streaming audio player class (AudioStreamer) for Mac OS X and iPhone.
69 stars 22 forks source link

Crash when invalid URL or a URL with preceding spaces is passed to the AudioStreamer #14

Closed Bo98 closed 12 years ago

Bo98 commented 12 years ago

There's two ways to crash the app here:

First one goes like this:

  1. User types in an invalid URL (eg. they enter "Test").
  2. User presses the play button.
  3. App crashes with EXC_BAD_ACCESS:
* thread #1: tid = 0x1d07, 0x00007fff979e4278 libobjc.A.dylib`_cache_getImp + 4, stop reason = EXC_BAD_ACCESS (code=13, address=0x0)
    frame #0: 0x00007fff979e4278 libobjc.A.dylib`_cache_getImp + 4
    frame #1: 0x00007fff979e5f51 libobjc.A.dylib`lookUpMethod + 41
    frame #2: 0x00007fff979e7d5e libobjc.A.dylib`class_respondsToSelector + 31
    frame #3: 0x00007fff97befc27 CoreFoundation`___forwarding___ + 391
    frame #4: 0x00007fff97befa28 CoreFoundation`_CF_forwarding_prep_0 + 232
    frame #5: 0x0000000100016fdd AudioStreamer`-[AudioStreamer closeReadStream] + 205 at AudioStreamer.m:1289
    frame #6: 0x0000000100012fd7 AudioStreamer`-[AudioStreamer stop] + 167 at AudioStreamer.m:310
    frame #7: 0x000000010000157b Mac Streaming Player`-[MacStreamingPlayerController destroyStreamer] + 267 at MacStreamingPlayerController.m:80
    frame #8: 0x0000000100002122 Mac Streaming Player`-[MacStreamingPlayerController playbackStateChanged:] + 354 at MacStreamingPlayerController.m:216
    frame #9: 0x00007fff97bb3b8a CoreFoundation`_CFXNotificationPost + 2554
    frame #10: 0x00007fff93fc6a76 Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 64
    frame #11: 0x0000000100013b2c AudioStreamer`-[AudioStreamer setState:] + 124 at AudioStreamer.m:485
    frame #12: 0x0000000100012f7b AudioStreamer`-[AudioStreamer stop] + 75 at AudioStreamer.m:303
    frame #13: 0x0000000100013aa9 AudioStreamer`-[AudioStreamer failWithErrorCode:] + 201 at AudioStreamer.m:476
    frame #14: 0x00000001000149a0 AudioStreamer`-[AudioStreamer openReadStream] + 2208 at AudioStreamer.m:669
    frame #15: 0x0000000100012ca6 AudioStreamer`-[AudioStreamer start] + 246 at AudioStreamer.m:268
    frame #16: 0x0000000100001f81 Mac Streaming Player`-[MacStreamingPlayerController buttonPressed:] + 353 at MacStreamingPlayerController.m:190
    frame #17: 0x00007fff9359a219 AppKit`-[NSApplication sendAction:to:from:] + 342
    frame #18: 0x00007fff9359a077 AppKit`-[NSControl sendAction:to:] + 85
    frame #19: 0x00007fff93599fab AppKit`-[NSCell _sendActionFrom:] + 138
    frame #20: 0x00007fff93598493 AppKit`-[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 1855
    frame #21: 0x00007fff93597ce1 AppKit`-[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 504
    frame #22: 0x00007fff9359745c AppKit`-[NSControl mouseDown:] + 820
    frame #23: 0x00007fff9358edce AppKit`-[NSWindow sendEvent:] + 6853
    frame #24: 0x00007fff9358af04 AppKit`-[NSApplication sendEvent:] + 5761
    frame #25: 0x00007fff934a0c7a AppKit`-[NSApplication run] + 636
    frame #26: 0x00007fff93445656 AppKit`NSApplicationMain + 869
    frame #27: 0x0000000100001262 Mac Streaming Player`main + 34 at main.m:36
    frame #28: 0x0000000100001234 Mac Streaming Player`start + 52

Second way:

  1. User enters a valid URL with a preceding space.
  2. User presses play.
  3. App crashes with EXC_BAD_ACCESS:
* thread #1: tid = 0x1d07, 0x00007fff979e42d0 libobjc.A.dylib`objc_msgSend + 16, stop reason = EXC_BAD_ACCESS (code=13, address=0x0)
    frame #0: 0x00007fff979e42d0 libobjc.A.dylib`objc_msgSend + 16
    frame #1: 0x0000000100016fdd AudioStreamer`-[AudioStreamer closeReadStream] + 205 at AudioStreamer.m:1289
    frame #2: 0x0000000100012fd7 AudioStreamer`-[AudioStreamer stop] + 167 at AudioStreamer.m:310
    frame #3: 0x000000010000157b Mac Streaming Player`-[MacStreamingPlayerController destroyStreamer] + 267 at MacStreamingPlayerController.m:80
    frame #4: 0x0000000100002122 Mac Streaming Player`-[MacStreamingPlayerController playbackStateChanged:] + 354 at MacStreamingPlayerController.m:216
    frame #5: 0x00007fff97bb3b8a CoreFoundation`_CFXNotificationPost + 2554
    frame #6: 0x00007fff93fc6a76 Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 64
    frame #7: 0x0000000100013b2c AudioStreamer`-[AudioStreamer setState:] + 124 at AudioStreamer.m:485
    frame #8: 0x0000000100012f7b AudioStreamer`-[AudioStreamer stop] + 75 at AudioStreamer.m:303
    frame #9: 0x0000000100013aa9 AudioStreamer`-[AudioStreamer failWithErrorCode:] + 201 at AudioStreamer.m:476
    frame #10: 0x00000001000149a0 AudioStreamer`-[AudioStreamer openReadStream] + 2208 at AudioStreamer.m:669
    frame #11: 0x0000000100012ca6 AudioStreamer`-[AudioStreamer start] + 246 at AudioStreamer.m:268
    frame #12: 0x0000000100001f81 Mac Streaming Player`-[MacStreamingPlayerController buttonPressed:] + 353 at MacStreamingPlayerController.m:190
    frame #13: 0x00007fff9359a219 AppKit`-[NSApplication sendAction:to:from:] + 342
    frame #14: 0x00007fff9359a077 AppKit`-[NSControl sendAction:to:] + 85
    frame #15: 0x00007fff93599fab AppKit`-[NSCell _sendActionFrom:] + 138
    frame #16: 0x00007fff93598493 AppKit`-[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 1855
    frame #17: 0x00007fff93597ce1 AppKit`-[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 504
    frame #18: 0x00007fff9359745c AppKit`-[NSControl mouseDown:] + 820
    frame #19: 0x00007fff9358edce AppKit`-[NSWindow sendEvent:] + 6853
    frame #20: 0x00007fff9358af04 AppKit`-[NSApplication sendEvent:] + 5761
    frame #21: 0x00007fff934a0c7a AppKit`-[NSApplication run] + 636
    frame #22: 0x00007fff93445656 AppKit`NSApplicationMain + 869
    frame #23: 0x0000000100001262 Mac Streaming Player`main + 34 at main.m:36
    frame #24: 0x0000000100001234 Mac Streaming Player`start + 52

The second way can occasionally not crash but instead spit out an error into the output box but it will crash with the same backtrace as above when you click the spinning button. Below is the error that can occasionally get outputted to the debug area:

(
    0   CoreFoundation                      0x00007fff97c01716 __exceptionPreprocess + 198
    1   libobjc.A.dylib                     0x00007fff979ef470 objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff97c97d5a -[NSObject(NSObject) doesNotRecognizeSelector:] + 186
    3   CoreFoundation                      0x00007fff97befc3e ___forwarding___ + 414
    4   CoreFoundation                      0x00007fff97befa28 _CF_forwarding_prep_0 + 232
    5   AudioStreamer                       0x0000000100016fdd -[AudioStreamer closeReadStream] + 205
    6   AudioStreamer                       0x0000000100012fd7 -[AudioStreamer stop] + 167
    7   Mac Streaming Player                0x000000010000155b -[MacStreamingPlayerController destroyStreamer] + 267
    8   Mac Streaming Player                0x0000000100002112 -[MacStreamingPlayerController playbackStateChanged:] + 354
    9   CoreFoundation                      0x00007fff97bb3b8a _CFXNotificationPost + 2554
    10  Foundation                          0x00007fff93fc6a76 -[NSNotificationCenter postNotificationName:object:userInfo:] + 64
    11  AudioStreamer                       0x0000000100013b2c -[AudioStreamer setState:] + 124
    12  AudioStreamer                       0x0000000100012f7b -[AudioStreamer stop] + 75
    13  AudioStreamer                       0x0000000100013aa9 -[AudioStreamer failWithErrorCode:] + 201
    14  AudioStreamer                       0x00000001000149a0 -[AudioStreamer openReadStream] + 2208
    15  AudioStreamer                       0x0000000100012ca6 -[AudioStreamer start] + 246
    16  Mac Streaming Player                0x0000000100001f71 -[MacStreamingPlayerController buttonPressed:] + 353
    17  AppKit                              0x00007fff9359a219 -[NSApplication sendAction:to:from:] + 342
    18  AppKit                              0x00007fff9359a077 -[NSControl sendAction:to:] + 85
    19  AppKit                              0x00007fff93599fab -[NSCell _sendActionFrom:] + 138
    20  AppKit                              0x00007fff93598493 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 1855
    21  AppKit                              0x00007fff93597ce1 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 504
    22  AppKit                              0x00007fff9359745c -[NSControl mouseDown:] + 820
    23  AppKit                              0x00007fff9358edce -[NSWindow sendEvent:] + 6853
    24  AppKit                              0x00007fff9358af04 -[NSApplication sendEvent:] + 5761
    25  AppKit                              0x00007fff934a0c7a -[NSApplication run] + 636
    26  AppKit                              0x00007fff93445656 NSApplicationMain + 869
    27  Mac Streaming Player                0x0000000100001242 main + 34
    28  Mac Streaming Player                0x0000000100001214 start + 52
)

There are a couple of other errors that can sometimes show up but it all comes down to the same problem.

Bo98 commented 12 years ago

The pull request should fix this.