Skip to content
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

EXC_BREAKPOINT DemandBuffer.swift:111 BUG IN CLIENT OF LIBPLATFORM: Trying to recursively lock an os_unfair_lock #114

Open
dsk1306 opened this issue Jan 18, 2022 · 8 comments

Comments

@dsk1306
Copy link
Contributor

dsk1306 commented Jan 18, 2022

I've just received a huge amount of crash reports caused by an exception during theDemandBuffer deallocation on iOS 13.

CrashReporter Key:  fdb68c604e035dc1461eb2f1d3466cd19894c442
Hardware Model:     iPhone8,4
Role:               Foreground
OS Version:         iOS 13.5.1
Exception Type:     EXC_BREAKPOINT 
Exception Subtype:  KERN_INVALID_ADDRESS


EXC_BREAKPOINT: BUG IN CLIENT OF LIBPLATFORM: Trying to recursively lock an os_unfair_lock

0   libsystem_platform.dylib __os_unfair_lock_recursive_abort
1   libsystem_platform.dylib __os_unfair_lock_lock_slow
2   Combine                  Publishers.ReceiveOn.Inner.receive(completion:)
3   Combine                  protocol witness for Subscriber.receive(completion:) in conformance Publishers.ReceiveOn<A, B>.Inner<A1>
4   Combine                  AnySubscriberBox.receive(completion:)
5   Combine                  protocol witness for Subscriber.receive(completion:) in conformance AnySubscriber<A, B>
6   HomeCodes                flush (DemandBuffer.swift:111:24)
7   HomeCodes                complete (DemandBuffer.swift:70:13)
8   HomeCodes                receive (Sink.swift:75:20)
9   HomeCodes                receive (CurrentValueRelay.swift:96:19)
10  HomeCodes                partial apply for closure #1 in CurrentValueRelay.deinit (CurrentValueRelay.swift:55:36)
11  HomeCodes                partial apply for thunk for @callee_guaranteed (@guaranteed CurrentValueRelay<A>.Subscription<CurrentValueSubject<A, Never>, AnySubscriber<A, Never>>) -> (@error @owned Error) (<compiler-generated>)
12  libswiftCore.dylib       Sequence.forEach(_:)
13  HomeCodes                deinit (CurrentValueRelay.swift:55:23)
14  HomeCodes                deinit (CurrentValueRelay.swift)
15  libswiftCore.dylib       __swift_release_dealloc
16  Combine                  PublisherBox.__deallocating_deinit
17  libswiftCore.dylib       __swift_release_dealloc
18  Combine                  outlined destroy of Publishers.ReceiveOn<A, B>.Inner<A1>.State
19  Combine                  protocol witness for Cancellable.cancel() in conformance Publishers.ReceiveOn<A, B>.Inner<A1>
20  Combine                  Subscribers.Sink.cancel()
21  Combine                  protocol witness for Cancellable.cancel() in conformance Subscribers.Sink<A, B>
22  Combine                  partial apply
23  Combine                  AnyCancellable.__deallocating_deinit
24  libswiftCore.dylib       __swift_release_dealloc
25  libswiftCore.dylib       _swift_arrayDestroy
26  libswiftCore.dylib       _SetStorage.deinit
27  libswiftCore.dylib       _SetStorage.__deallocating_deinit
28  libswiftCore.dylib       __swift_release_dealloc
29  libobjc.A.dylib          object_cxxDestructFromClass(objc_object*, objc_class*)
30  libobjc.A.dylib          _objc_destructInstance
31  libobjc.A.dylib          __objc_rootDealloc
32  UIKitCore                -[UIResponder dealloc]
33  UIKitCore                -[UIViewController dealloc]
34  HomeCodes                deinit (<compiler-generated>)
35  CoreFoundation           ___RELEASE_OBJECTS_IN_THE_ARRAY__
36  CoreFoundation           -[__NSArrayM dealloc]
37  UIKitCore                -[UIViewController dealloc]
38  UIKitCore                -[UINavigationController dealloc]
39  HomeCodes                deinit (BaseCoordinator.swift)
40  HomeCodes                deinit (NavigationCoordinator.swift)
41  HomeCodes                deinit (BaseNavigationCoordinator.swift:32:5)
42  HomeCodes                deinit (BaseNavigationCoordinator.swift)
43  libswiftCore.dylib       __swift_release_dealloc
44  libswiftCore.dylib       bool swift::RefCounts<swift::SideTableRefCountBits>::doDecrement<(swift::PerformDeinit)1>(unsigned int)
45  libswiftCore.dylib       _swift_arrayDestroy
46  HomeCodes                specialized Array.replaceSubrange<A>(_:with:) (HomeCodes)
47  HomeCodes                BaseCoordinator.removeChildrenIfNeeded() (<compiler-generated>)
48  HomeCodes                removeChildrenIfNeeded (<compiler-generated>)
49  HomeCodes                childTransitionCompleted (Coordinator.swift:110:9)
50  HomeCodes                childTransitionCompleted (<compiler-generated>)
51  HomeCodes                partial apply for closure #1 in BaseCoordinator.registerParent(_:) (BaseCoordinator.swift:106:26)
52  HomeCodes                removeChildrenIfNeeded (BaseCoordinator.swift:75:9)
53  HomeCodes                removeChildrenIfNeeded (<compiler-generated>)
54  HomeCodes                childTransitionCompleted (Coordinator.swift:110:9)
55  HomeCodes                childTransitionCompleted (<compiler-generated>)
56  HomeCodes                navigationController (NavigationAnimationDelegate.swift:136:22)
57  HomeCodes                navigationController (<compiler-generated>)
58  UIKitCore                -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:]
59  UIKitCore                -[UINavigationTransitionView _notifyDelegateTransitionDidStopWithContext:]
60  UIKitCore                -[UINavigationTransitionView _cleanupTransition]
61  UIKitCore                +[UIView(UIViewAnimationWithBlocks) conditionallyAnimate:withAnimation:layout:completion:]
62  UIKitCore                -[UINavigationTransitionView transition:fromView:toView:]
63  UIKitCore                -[UINavigationController _startTransition:fromViewController:toViewController:]
64  UIKitCore                -[UINavigationController _startDeferredTransitionIfNeeded:]
65  UIKitCore                -[UINavigationController __viewWillLayoutSubviews]
66  UIKitCore                -[UILayoutContainerView layoutSubviews]
67  UIKitCore                -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
68  QuartzCore               -[CALayer layoutSublayers]
69  QuartzCore               CA::Layer::layout_if_needed(CA::Transaction*)
70  UIKitCore                -[UIView(Hierarchy) layoutBelowIfNeeded]
71  UIKitCore                -[_UISheetPresentationController _sheetLayoutInfoLayout:]
72  UIKitCore                -[_UISheetLayoutInfo _layout]
73  UIKitCore                ___54-[_UISheetPresentationController transitionWillBegin:]_block_invoke_2
74  UIKitCore                +[UIView(Animation) performWithoutAnimation:]
75  UIKitCore                ___54-[_UISheetPresentationController transitionWillBegin:]_block_invoke.341
76  UIKitCore                -[_UIViewControllerTransitionCoordinator _applyBlocks:releaseBlocks:]
77  UIKitCore                -[_UIViewControllerTransitionContext __runAlongsideAnimations]
78  UIKitCore                ___63+[UIView(Animation) _setAlongsideAnimations:toRunByEndOfBlock:]_block_invoke
79  UIKitCore                -[UIViewAnimationState _runAlongsideAnimations]
80  UIKitCore                -[UIViewAnimationState pop]
81  UIKitCore                +[UIViewAnimationState popAnimationState]
82  UIKitCore                +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:]
83  UIKitCore                +[UIView(UIViewAnimationWithBlocks) animateWithDuration:delay:options:animations:completion:]
84  UIKitCore                ___50-[UITransitionView _startTransition:withDuration:]_block_invoke.169
85  UIKitCore                +[UIView(UIViewAnimationWithBlocks) conditionallyAnimate:withAnimation:layout:completion:]
86  UIKitCore                -[UITransitionView _startTransition:withDuration:]
87  UIKitCore                -[UITransitionView transition:fromView:toView:removeFromView:]
88  UIKitCore                -[UIViewControllerBuiltinTransitionViewAnimator animateTransition:]
89  UIKitCore                ____UIViewControllerTransitioningRunCustomTransition_block_invoke_2
90  UIKitCore                +[UIInputResponderController _pinInputViewsForInputResponderController:onBehalfOfResponder:duringBlock:]
91  UIKitCore                ____UIViewControllerTransitioningRunCustomTransition_block_invoke.645
92  UIKitCore                +[UIView(Animation) _setAlongsideAnimations:toRunByEndOfBlock:]
93  UIKitCore                __UIViewControllerTransitioningRunCustomTransition
94  UIKitCore                ___56-[UIPresentationController runTransitionForCurrentState]_block_invoke.465
95  UIKitCore                __runAfterCACommitDeferredBlocks
96  UIKitCore                __cleanUpAfterCAFlushAndRunDeferredBlocks
97  UIKitCore                __afterCACommitHandler
98  CoreFoundation           ___CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
99  CoreFoundation           ___CFRunLoopDoObservers
100 CoreFoundation           ___CFRunLoopRun
101 CoreFoundation           _CFRunLoopRunSpecific
102 GraphicsServices         _GSEventRunModal
103 UIKitCore                _UIApplicationMain
104 HomeCodes                main (main.swift:8:1)
105 libdyld.dylib            _start

I've tried to repro it and it looks like it just enough to create a publisher that uses DemandBuffer (e.g. CurrentValueRelay), initialise it and the just deinit it. And it looks like it only reproducible on iOS 13.5 and older.
Did anyone else had the same issue?

@freak4pc
Copy link
Member

Does it happen with operators that use DemandBuffer? Or is it just CurrentValueRelay?

@dsk1306
Copy link
Contributor Author

dsk1306 commented Jan 18, 2022

@freak4pc I've managed to repro it with CurrentValueRelay, .share(replay:) and PassthroughRelay.

@freak4pc
Copy link
Member

Those all use Relays I believe. Would be interesting to see if it happens with just random non-subject/relay operators.

@nimaen
Copy link

nimaen commented Mar 28, 2022

Hi, I've started having those kind of errors as well using a ReplaySubject.
Is this still a main topic ?

@freak4pc
Copy link
Member

I unfortunately don't have the time to debug this anytime soon, but happy to review a PR if anyone wants to dig into this and find a trustworthy fix.

Thanks!

@freak4pc
Copy link
Member

freak4pc commented Aug 4, 2022

@dsk1306 sorry to awaken this thread but any change you have an example that can reproduce this somewhere ? I know it's been a while but seems like this is still happening.

@dsk1306
Copy link
Contributor Author

dsk1306 commented Aug 4, 2022

@freak4pc Sorry, we dropped iOS 13 support in our app 🤷🏻‍♂️ So I cannot provide any more details.

@tureck1y
Copy link

tureck1y commented Feb 7, 2024

Same issue on iOS 17.2.1

Crashed: com.apple.main-thread
0  libsystem_platform.dylib       0x620c _os_unfair_lock_recursive_abort + 36
1  libsystem_platform.dylib       0x3348 _os_unfair_lock_lock_slow + 284
2  Combine                        0x27858 AbstractCombineLatest.cancel() + 64
3  Combine                        0x2780c protocol witness for Cancellable.cancel() in conformance AbstractCombineLatest<A, B, C> + 24
4  Combine                        0x27660 Subscribers.Sink.cancel() + 636
5  Combine                        0x273d8 protocol witness for Cancellable.cancel() in conformance Subscribers.Sink<A, B> + 24
6  Combine                        0x272ec AnyCancellable.cancel() + 212
7  Combine                        0x271dc AnyCancellable.__deallocating_deinit + 16
8  libswiftCore.dylib             0x3a6914 _swift_release_dealloc + 56
9  libswiftCore.dylib             0x3a7fb0 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 136
10 libswiftCore.dylib             0x393298 swift_arrayDestroy + 124
11 libswiftCore.dylib             0x1d7acc _SetStorage.deinit + 220
12 libswiftCore.dylib             0x1d7b30 _SetStorage.__deallocating_deinit + 16
13 libswiftCore.dylib             0x3a6914 _swift_release_dealloc + 56
14 libswiftCore.dylib             0x3a7fb0 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 136
15 Tangem                         0x586dc0 main + 4457564
16 libswiftCore.dylib             0x3a6914 _swift_release_dealloc + 56
17 libswiftCore.dylib             0x3a7fb0 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 136
18 Tangem                         0x2c9f38 main + 1586644
19 Tangem                         0x2c9fac main + 1586760
20 libswiftCore.dylib             0x3a6914 _swift_release_dealloc + 56
21 libswiftCore.dylib             0x3a7fb0 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 136
22 Tangem                         0x4888b4 main + 3415888
23 libswiftCore.dylib             0x3a6914 _swift_release_dealloc + 56
24 libswiftCore.dylib             0x3a7fb0 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 136
25 Tangem                         0x488224 main + 3414208
26 libswiftCore.dylib             0x3a6914 _swift_release_dealloc + 56
27 libswiftCore.dylib             0x3a7fb0 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 136
28 Tangem                         0x488224 main + 3414208
29 libswiftCore.dylib             0x3a6914 _swift_release_dealloc + 56
30 libswiftCore.dylib             0x3a7fb0 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 136
31 Tangem                         0x411fec main + 2930312
32 libswiftCore.dylib             0x393298 swift_arrayDestroy + 124
33 libswiftCore.dylib             0x9c5a4 _ContiguousArrayStorage.__deallocating_deinit + 96
34 libswiftCore.dylib             0x3a6914 _swift_release_dealloc + 56
35 libswiftCore.dylib             0x3a7fb0 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 136
36 Tangem                         0x5a0354 main + 4561392
37 libswiftCore.dylib             0x393298 swift_arrayDestroy + 124
38 libswiftCore.dylib             0x9c5a4 _ContiguousArrayStorage.__deallocating_deinit + 96
39 libswiftCore.dylib             0x3a6914 _swift_release_dealloc + 56
40 libswiftCore.dylib             0x3a7fb0 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 136
41 libswiftCore.dylib             0x3a9fe4 swift::metadataimpl::ValueWitnesses<swift::metadataimpl::BridgeObjectBox>::assignWithTake(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*) + 36
42 libswiftCore.dylib             0x3c6e30 swift::metadataimpl::OpaqueExistentialBox<0u>::Container* swift::metadataimpl::OpaqueExistentialBoxBase::assignWithTake<swift::metadataimpl::OpaqueExistentialBox<0u>::Container>(swift::metadataimpl::OpaqueExistentialBox<0u>::Container*, swift::metadataimpl::OpaqueExistentialBox<0u>::Container*) + 568
43 libswiftCore.dylib             0x37fc54 assignWithTake for ClosedRange<>.Index + 336
44 Combine                        0x917c outlined assign with take of Subscription? + 84
45 Combine                        0xd768 AbstractCombineLatest.receive(_:index:) + 456
46 Combine                        0xd57c AbstractCombineLatest.Side.receive(_:) + 112
47 Combine                        0x19434 Publishers.Map.Inner.receive(_:) + 200
48 Combine                        0x19434 Publishers.Map.Inner.receive(_:) + 200
49 Combine                        0xd940 AbstractCombineLatest.receive(_:index:) + 928
50 Combine                        0xd57c AbstractCombineLatest.Side.receive(_:) + 112
51 Combine                        0x19434 Publishers.Map.Inner.receive(_:) + 200
52 Combine                        0x29808 Publishers.Autoconnect.Inner.receive(_:) + 52
53 Combine                        0x29764 Publishers.Multicast.Inner.receive(_:) + 236
54 Combine                        0x2966c protocol witness for Subscriber.receive(_:) in conformance Publishers.Multicast<A, B>.Inner<A1> + 24
55 Combine                        0x29648 AnySubscriberBox.receive(_:) + 108
56 Combine                        0x295d0 protocol witness for Subscriber.receive(_:) in conformance AnySubscriber<A, B> + 56
57 CombineExt                     0xbcf8 DemandBuffer.buffer(value:) + 51 (DemandBuffer.swift:51)
58 CombineExt                     0x17afc ReplaySubject.Subscription.forwardValueToBuffer(_:) + 134 (ReplaySubject.swift:134)
59 CombineExt                     0x18ee0 partial apply for closure #1 in ReplaySubject.send(_:) + 32
60 CombineExt                     0x18e9c partial apply for closure #1 in ReplaySubject.send(_:) + 20
61 libswiftCore.dylib             0xdd538 Sequence.forEach(_:) + 740
62 CombineExt                     0x17a68 ReplaySubject.send(_:) + 57 (ReplaySubject.swift:57)
63 Combine                        0x1a1c8 SubjectSubscriber.receive(_:) + 188
64 Combine                        0x1a0fc protocol witness for Subscriber.receive(_:) in conformance SubjectSubscriber<A> + 24
65 Combine                        0xd448 FilterProducer.receive(_:) + 2520
66 Combine                        0xca64 protocol witness for Subscriber.receive(_:) in conformance FilterProducer<A, B, C, D, E> + 24
67 Combine                        0x56a4 closure #1 in Publishers.ReceiveOn.Inner.receive(_:) + 276
68 libswiftDispatch.dylib         0xe5d8 thunk for @escaping @callee_guaranteed () -> () + 36
69 libdispatch.dylib              0x26a8 _dispatch_call_block_and_release + 32
70 libdispatch.dylib              0x4300 _dispatch_client_callout + 20
71 libdispatch.dylib              0x12998 _dispatch_main_queue_drain + 984
72 libdispatch.dylib              0x125b0 _dispatch_main_queue_callback_4CF + 44
73 CoreFoundation                 0x3701c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
74 CoreFoundation                 0x33d28 __CFRunLoopRun + 1996
75 CoreFoundation                 0x33478 CFRunLoopRunSpecific + 608
76 GraphicsServices               0x34f8 GSEventRunModal + 164
77 UIKitCore                      0x22c62c -[UIApplication _run] + 888
78 UIKitCore                      0x22bc68 UIApplicationMain + 340
79 Tangem                         0x1469a4 main + 64
80 ???                            0x1bb32adcc (Missing)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants