New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deadlock in RACLiveSubscriber #1002

Closed
nikolaykasyanov opened this Issue Dec 13, 2013 · 4 comments

Comments

Projects
None yet
2 participants
@nikolaykasyanov
Contributor

nikolaykasyanov commented Dec 13, 2013

I tried 3.0 branch recently and got a deadlock:

* thread #1: tid = 0x6cca16, 0x02f77802 libsystem_kernel.dylib`__psynch_mutexwait + 10, queue = 'com.apple.main-thread, stop reason = signal SIGSTOP
frame #0: 0x02f77802 libsystem_kernel.dylib`__psynch_mutexwait + 10
frame #1: 0x02f3d945 libsystem_pthread.dylib`_pthread_mutex_lock + 404
frame #2: 0x02f3d7ac libsystem_pthread.dylib`pthread_mutex_lock + 16
frame #3: 0x0212a448 libobjc.A.dylib`objc_sync_enter + 48
frame #4: 0x001d0c05 app`__25-[RACLiveSubscriber init]_block_invoke(.block_descriptor=<unavailable>) + 181 at RACLiveSubscriber.m:86
frame #5: 0x001c5749 app`-[RACDisposable dispose](self=0x0a9fa4b0, _cmd=0x00233ef3) + 201 at RACDisposable.m:83
frame #6: 0x001c4913 app`-[RACCompoundDisposable dispose](self=0x0a9364d0, _cmd=0x00233ef3) + 355 at RACCompoundDisposable.m:228
frame #7: 0x001c4a91 app`disposeEach(value=0x0a9364d0, context=0x00000000) + 81 at RACCompoundDisposable.m:198
frame #8: 0x0233bd59 CoreFoundation`CFArrayApplyFunction + 57
frame #9: 0x001c49a3 app`-[RACCompoundDisposable dispose](self=0x114bc620, _cmd=0x00233ef3) + 499 at RACCompoundDisposable.m:235
frame #10: 0x001d175b app`-[RACLiveSubscriber sendCompleted](self=0x0a978bc0, _cmd=0x0021b1ef) + 235 at RACLiveSubscriber.m:134
frame #11: 0x001efa43 app`__35-[RACSignal(.block_descriptor=0x1147def0, _=0x0a96ff70) takeUntil:]_block_invoke_2 + 99 at RACSignal+Operations.m:760
frame #12: 0x001d1037 app`-[RACLiveSubscriber sendNext:](self=0x0a905890, _cmd=0x0021b1e5, value=0x0a96ff70) + 567 at RACLiveSubscriber.m:113
frame #13: 0x001fab4a app`__30-[RACSignal(.block_descriptor=0x0ab2f960, x=0x0a96ff70) bind:]_block_invoke921 + 106 at RACSignal+Operations.m:1205
frame #14: 0x001d1037 app`-[RACLiveSubscriber sendNext:](self=0x11a775d0, _cmd=0x0021b1e5, value=0x0a96ff70) + 567 at RACLiveSubscriber.m:113
frame #15: 0x001d5a11 app`-[RACReturnSignal attachSubscriber:](self=0x0aba5830, _cmd=0x00233488, subscriber=0x11a775d0) + 385 at RACReturnSignal.m:85
frame #16: 0x0020031a app`-[RACSignal(self=0x0aba5830, _cmd=0x002342f9, saveDisposableBlock=0xbfffb3c8, nextBlock=0xbfffb3b0, errorBlock=0xbfffb398, completedBlock=0xbfffb378) subscribeSavingDisposable:next:error:completed:] + 634 at RACSignal.m:122
frame #17: 0x001fa8a0 app`__30-[RACSignal(.block_descriptor=0x1148b720, signal=0x0aba5830) bind:]_block_invoke916 + 880 at RACSignal+Operations.m:1202
frame #18: 0x001fb132 app`__30-[RACSignal(.block_descriptor=0x0a90cc70, x=0x0a96ff70) bind:]_block_invoke940 + 146 at RACSignal+Operations.m:1226
frame #19: 0x001d1037 app`-[RACLiveSubscriber sendNext:](self=0x114b51a0, _cmd=0x0021b1e5, value=0x0a96ff70) + 567 at RACLiveSubscriber.m:113
frame #20: 0x001fab4a app`__30-[RACSignal(.block_descriptor=0x0abd0620, x=0x0a96ff70) bind:]_block_invoke921 + 106 at RACSignal+Operations.m:1205
frame #21: 0x001d1037 app`-[RACLiveSubscriber sendNext:](self=0x0abee9b0, _cmd=0x0021b1e5, value=0x0a96ff70) + 567 at RACLiveSubscriber.m:113
frame #22: 0x001d5a11 app`-[RACReturnSignal attachSubscriber:](self=0x0abc2da0, _cmd=0x00233488, subscriber=0x0abee9b0) + 385 at RACReturnSignal.m:85
frame #23: 0x0020031a app`-[RACSignal(self=0x0abc2da0, _cmd=0x002342f9, saveDisposableBlock=0xbfffb7c8, nextBlock=0xbfffb7b0, errorBlock=0xbfffb798, completedBlock=0xbfffb778) subscribeSavingDisposable:next:error:completed:] + 634 at RACSignal.m:122
frame #24: 0x001fa8a0 app`__30-[RACSignal(.block_descriptor=0x1148a360, signal=0x0abc2da0) bind:]_block_invoke916 + 880 at RACSignal+Operations.m:1202
frame #25: 0x001fb132 app`__30-[RACSignal(.block_descriptor=0x11478840, x=0x0a96ff70) bind:]_block_invoke940 + 146 at RACSignal+Operations.m:1226
frame #26: 0x001d1037 app`-[RACLiveSubscriber sendNext:](self=0x0a925310, _cmd=0x0021b1e5, value=0x0a96ff70) + 567 at RACLiveSubscriber.m:113
frame #27: 0x001fab4a app`__30-[RACSignal(.block_descriptor=0x0abee0d0, x=0x0a96ff70) bind:]_block_invoke921 + 106 at RACSignal+Operations.m:1205
frame #28: 0x001d1037 app`-[RACLiveSubscriber sendNext:](self=0x0abe0780, _cmd=0x0021b1e5, value=0x0a96ff70) + 567 at RACLiveSubscriber.m:113
frame #29: 0x001d5a11 app`-[RACReturnSignal attachSubscriber:](self=0x0a9c9250, _cmd=0x00233488, subscriber=0x0abe0780) + 385 at RACReturnSignal.m:85
frame #30: 0x0020031a app`-[RACSignal(self=0x0a9c9250, _cmd=0x002342f9, saveDisposableBlock=0xbfffbbc8, nextBlock=0xbfffbbb0, errorBlock=0xbfffbb98, completedBlock=0xbfffbb78) subscribeSavingDisposable:next:error:completed:] + 634 at RACSignal.m:122
frame #31: 0x001fa8a0 app`__30-[RACSignal(.block_descriptor=0x114bb510, signal=0x0a9c9250) bind:]_block_invoke916 + 880 at RACSignal+Operations.m:1202
frame #32: 0x001fb132 app`__30-[RACSignal(.block_descriptor=0x0a9ef7a0, x=0x0a96ff70) bind:]_block_invoke940 + 146 at RACSignal+Operations.m:1226
frame #33: 0x001d1037 app`-[RACLiveSubscriber sendNext:](self=0x114bb240, _cmd=0x0021b1e5, value=0x0a96ff70) + 567 at RACLiveSubscriber.m:113
frame #34: 0x001fab4a app`__30-[RACSignal(.block_descriptor=0x0a9b8d90, x=0x0a96ff70) bind:]_block_invoke921 + 106 at RACSignal+Operations.m:1205
frame #35: 0x001d1037 app`-[RACLiveSubscriber sendNext:](self=0x0a9982c0, _cmd=0x0021b1e5, value=0x0a96ff70) + 567 at RACLiveSubscriber.m:113
frame #36: 0x001d5a11 app`-[RACReturnSignal attachSubscriber:](self=0x0a9e8ad0, _cmd=0x00233488, subscriber=0x0a9982c0) + 385 at RACReturnSignal.m:85
frame #37: 0x0020031a app`-[RACSignal(self=0x0a9e8ad0, _cmd=0x002342f9, saveDisposableBlock=0xbfffbfc8, nextBlock=0xbfffbfb0, errorBlock=0xbfffbf98, completedBlock=0xbfffbf78) subscribeSavingDisposable:next:error:completed:] + 634 at RACSignal.m:122
frame #38: 0x001fa8a0 app`__30-[RACSignal(.block_descriptor=0x0a9efa80, signal=0x0a9e8ad0) bind:]_block_invoke916 + 880 at RACSignal+Operations.m:1202
frame #39: 0x001fb132 app`__30-[RACSignal(.block_descriptor=0x114782e0, x=0x0a9648e0) bind:]_block_invoke940 + 146 at RACSignal+Operations.m:1226
frame #40: 0x001d1037 app`-[RACLiveSubscriber sendNext:](self=0x1146f460, _cmd=0x0021b1e5, value=0x0a9648e0) + 567 at RACLiveSubscriber.m:113
frame #41: 0x001b3948 app`__84-[NSObject(.block_descriptor=0x0a9cab40, value=0x0a96ff70, change=0x0a997370) rac_valuesAndChangesForKeyPath:options:observer:]_block_invoke_2 + 440 at NSObject+RACPropertySubscribing.m:49
frame #42: 0x001b16d8 app`__69-[NSObject(.block_descriptor=0x114775f0, trampolineTarget=0x0ab8c4b0, trampolineObserver=0x0a96ff30, change=0x0a997370) rac_observeKeyPath:options:observer:block:]_block_invoke81 + 1048 at NSObject+RACKVOWrapper.m:170
frame #43: 0x001cfafd app`-[RACKVOTrampoline observeValueForKeyPath:ofObject:change:context:](self=0x0a945f00, _cmd=0x00b2c4de, keyPath=0x0ac98330, object=0x0ab8c4b0, change=0x0a9b2810, context=0x002dd250) + 589 at RACKVOTrampoline.m:97
frame #44: 0x009938c7 Foundation`NSKeyValueNotifyObserver + 362
frame #45: 0x00995206 Foundation`NSKeyValueDidChange + 458
frame #46: 0x009518dd Foundation`-[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] + 120
frame #47: 0x00997133 Foundation`_NSSetCharValueAndNotify + 171
frame #48: 0x009c9755 Foundation`_NSSetCharValueForKeyWithMethod + 87
frame #49: 0x00971da3 Foundation`_NSSetUsingKeyValueSetter + 256
frame #50: 0x00971253 Foundation`-[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
frame #51: 0x009d370a Foundation`-[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
frame #52: 0x001ee4c7 app`__54-[RACSignal(.block_descriptor=0x0aa6e520, x=0x0a96ff70) setKeyPath:onObject:nilValue:]_block_invoke + 183 at RACSignal+Operations.m:679
frame #53: 0x001d1037 app`-[RACLiveSubscriber sendNext:](self=0x0aa6e3c0, _cmd=0x0021b1e5, value=0x0a96ff70) + 567 at RACLiveSubscriber.m:113
frame #54: 0x001fab4a app`__30-[RACSignal(.block_descriptor=0x0a9f0e60, x=0x0a96ff70) bind:]_block_invoke921 + 106 at RACSignal+Operations.m:1205
frame #55: 0x001d1037 app`-[RACLiveSubscriber sendNext:](self=0x1147f940, _cmd=0x0021b1e5, value=0x0a96ff70) + 567 at RACLiveSubscriber.m:113
frame #56: 0x001d5a11 app`-[RACReturnSignal attachSubscriber:](self=0x0a9adaa0, _cmd=0x00233488, subscriber=0x1147f940) + 385 at RACReturnSignal.m:85
frame #57: 0x0020031a app`-[RACSignal(self=0x0a9adaa0, _cmd=0x002342f9, saveDisposableBlock=0xbfffc928, nextBlock=0xbfffc910, errorBlock=0xbfffc8f8, completedBlock=0xbfffc8d8) subscribeSavingDisposable:next:error:completed:] + 634 at RACSignal.m:122
frame #58: 0x001fa8a0 app`__30-[RACSignal(.block_descriptor=0x0aa6e700, signal=0x0a9adaa0) bind:]_block_invoke916 + 880 at RACSignal+Operations.m:1202
frame #59: 0x001fb132 app`__30-[RACSignal(.block_descriptor=0x0aa6e960, x=0x00000000) bind:]_block_invoke940 + 146 at RACSignal+Operations.m:1226
frame #60: 0x001d1037 app`-[RACLiveSubscriber sendNext:](self=0x0aa6e8e0, _cmd=0x0021b1e5, value=0x00000000) + 567 at RACLiveSubscriber.m:113
frame #61: 0x001fab4a app`__30-[RACSignal(.block_descriptor=0x114bb450, x=0x00000000) bind:]_block_invoke921 + 106 at RACSignal+Operations.m:1205
frame #62: 0x001d1037 app`-[RACLiveSubscriber sendNext:](self=0x0a9ce410, _cmd=0x0021b1e5, value=0x00000000) + 567 at RACLiveSubscriber.m:113
frame #63: 0x001d5a11 app`-[RACReturnSignal attachSubscriber:](self=0x114b5490, _cmd=0x00233488, subscriber=0x0a9ce410) + 385 at RACReturnSignal.m:85
frame #64: 0x0020031a app`-[RACSignal(self=0x114b5490, _cmd=0x002342f9, saveDisposableBlock=0xbfffcd28, nextBlock=0xbfffcd10, errorBlock=0xbfffccf8, completedBlock=0xbfffccd8) subscribeSavingDisposable:next:error:completed:] + 634 at RACSignal.m:122
frame #65: 0x001fa8a0 app`__30-[RACSignal(.block_descriptor=0x0aa6eae0, signal=0x114b5490) bind:]_block_invoke916 + 880 at RACSignal+Operations.m:1202
frame #66: 0x001fb132 app`__30-[RACSignal(.block_descriptor=0x0aa6ebe0, x=0x1148ee80) bind:]_block_invoke940 + 146 at RACSignal+Operations.m:1226
frame #67: 0x001d1037 app`-[RACLiveSubscriber sendNext:](self=0x0aa6eb60, _cmd=0x0021b1e5, value=0x1148ee80) + 567 at RACLiveSubscriber.m:113
frame #68: 0x001b3948 app`__84-[NSObject(.block_descriptor=0x0aa6efa0, value=0x00000000, change=0x0a9f19f0) rac_valuesAndChangesForKeyPath:options:observer:]_block_invoke_2 + 440 at NSObject+RACPropertySubscribing.m:49
frame #69: 0x001b15f9 app`__69-[NSObject(.block_descriptor=0x0aa6ef60, trampolineTarget=0x0ab8c4b0, trampolineObserver=0x0ab8c4b0, change=0x0a9f19f0) rac_observeKeyPath:options:observer:block:]_block_invoke81 + 825 at NSObject+RACKVOWrapper.m:154
frame #70: 0x001cfafd app`-[RACKVOTrampoline observeValueForKeyPath:ofObject:change:context:](self=0x0aa6ef20, _cmd=0x00b2c4de, keyPath=0x0aa6d2d0, object=0x0ab8c4b0, change=0x0aadfa60, context=0x002dd250) + 589 at RACKVOTrampoline.m:97

thread #10: tid = 0x6ccabb, 0x02f77802 libsystem_kernel.dylib`__psynch_mutexwait + 10, queue = 'com.ReactiveCocoa.RACScheduler.backgroundScheduler
frame #0: 0x02f77802 libsystem_kernel.dylib`__psynch_mutexwait + 10
frame #1: 0x02f3d945 libsystem_pthread.dylib`_pthread_mutex_lock + 404
frame #2: 0x02f3d7ac libsystem_pthread.dylib`pthread_mutex_lock + 16
frame #3: 0x0212a448 libobjc.A.dylib`objc_sync_enter + 48
frame #4: 0x001d0e52 app`-[RACLiveSubscriber sendNext:](self=0x0a978bc0, _cmd=0x0021b1e5, value=0x0a92f260) + 82 at RACLiveSubscriber.m:105
frame #5: 0x001d031a app`__54+[RACLiveSubscriber subscriberForwardingToSubscriber:]_block_invoke(.block_descriptor=0x0a913630, x=0x0a92f260) + 106 at RACLiveSubscriber.m:51
frame #6: 0x001d1037 app`-[RACLiveSubscriber sendNext:](self=0x0a9ad970, _cmd=0x0021b1e5, value=0x0a92f260) + 567 at RACLiveSubscriber.m:113
frame #7: 0x001e0f1f app`__32-[RACSignal(.block_descriptor=0x1147fc80, x=0x0a92f260) doNext:]_block_invoke_2 + 127 at RACSignal+Operations.m:202
frame #8: 0x001d1037 app`-[RACLiveSubscriber sendNext:](self=0x0a9dc7c0, _cmd=0x0021b1e5, value=0x0a92f260) + 567 at RACLiveSubscriber.m:113
frame #9: 0x001f50b3 app`__35-[RACSignal(.block_descriptor=<unavailable>) deliverOn:]_block_invoke_3 + 51 at RACSignal+Operations.m:996
frame #10: 0x001d4385 app`-[RACQueueScheduler performAsCurrentScheduler:](self=0x0ab51210, _cmd=0x00233cfb, block=0x0a9e8a50) + 501 at RACQueueScheduler.m:111
frame #11: 0x001d32b3 app`__30-[RACQueueScheduler schedule:]_block_invoke(.block_descriptor=<unavailable>) + 99 at RACQueueScheduler.m:60
frame #12: 0x001bbbc5 app`__RACBacktraceBlock_block_invoke(.block_descriptor=0x1148ee60) + 101 at RACBacktrace.m:67
frame #13: 0x02ab57f8 libdispatch.dylib`_dispatch_call_block_and_release + 15
frame #14: 0x02aca4b0 libdispatch.dylib`_dispatch_client_callout + 14
frame #15: 0x02ab807f libdispatch.dylib`_dispatch_queue_drain + 452
frame #16: 0x02ab7e7a libdispatch.dylib`_dispatch_queue_invoke + 128
frame #17: 0x02ab8e1f libdispatch.dylib`_dispatch_root_queue_drain + 83
frame #18: 0x02ab9137 libdispatch.dylib`_dispatch_worker_thread2 + 39
frame #19: 0x02f3bdab libsystem_pthread.dylib`_pthread_wqthread + 336

Looks like two RACLiveSubscriber instances (0x0a978bc0 and another one, probably one that disposed on main thread __25-[RACLiveSubscriber init]_block_invoke(.block_descriptor=<unavailable>) + 181 at RACLiveSubscriber.m:86) locks each other.

Please let me know if any additional info is required.

Used commit: f4828f2

@jspahrsummers

This comment has been minimized.

Show comment
Hide comment
@jspahrsummers

jspahrsummers Dec 13, 2013

Member

The only way I could see this happening is with a couple mutually-recursive disposables. Do you have some sample code you could share?

Member

jspahrsummers commented Dec 13, 2013

The only way I could see this happening is with a couple mutually-recursive disposables. Do you have some sample code you could share?

@nikolaykasyanov

This comment has been minimized.

Show comment
Hide comment
@nikolaykasyanov

nikolaykasyanov Dec 17, 2013

Contributor

I'll try to provide some code

Contributor

nikolaykasyanov commented Dec 17, 2013

I'll try to provide some code

@jspahrsummers

This comment has been minimized.

Show comment
Hide comment
@jspahrsummers

jspahrsummers Feb 11, 2014

Member

Is this still an issue?

Member

jspahrsummers commented Feb 11, 2014

Is this still an issue?

@nikolaykasyanov

This comment has been minimized.

Show comment
Hide comment
@nikolaykasyanov

nikolaykasyanov Feb 12, 2014

Contributor

@jspahrsummers I'm using 3.0-dev in other project now, but didn't encounter this deadlock yet.
Feel free to close it for now.

Contributor

nikolaykasyanov commented Feb 12, 2014

@jspahrsummers I'm using 3.0-dev in other project now, but didn't encounter this deadlock yet.
Feel free to close it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment