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

Crash in MergeBasicSink with Xcode 11.2 #2099

Closed
5 of 18 tasks
akolov opened this issue Nov 1, 2019 · 9 comments
Closed
5 of 18 tasks

Crash in MergeBasicSink with Xcode 11.2 #2099

akolov opened this issue Nov 1, 2019 · 9 comments

Comments

@akolov
Copy link

akolov commented Nov 1, 2019

Short description of the issue:

I'm getting crashes when using merge() with Xcode 11.2. Same code with 11.1 works fine.

What actually happens:

EXC_BAD_ACCESS (code=1, address=0x0)

    frame #0: 0x00007fff5132ba49 libswiftCore.dylib`_swift_initClassMetadataImpl(swift::TargetClassMetadata<swift::InProcess>*, swift::ClassLayoutFlags, unsigned long, swift::TypeLayout const* const*, unsigned long*, bool) + 1337
    frame #1: 0x0000000106c0bc46 Test`type metadata completion function for MergeSink at <compiler-generated>:0
    frame #2: 0x00007fff51332ced libswiftCore.dylib`swift::MetadataCacheEntryBase<(anonymous namespace)::GenericCacheEntry, void const*>::doInitialization(swift::ConcurrencyControl&, swift::MetadataCompletionQueueEntry*, swift::MetadataRequest) + 285
    frame #3: 0x00007fff51329767 libswiftCore.dylib`swift_getGenericMetadata + 1527
    frame #4: 0x0000000106c0bc90 Test`type metadata accessor for MergeSink at <compiler-generated>:0
    frame #5: 0x00007fff513420e1 libswiftCore.dylib`(anonymous namespace)::DecodedMetadataBuilder::createBoundGenericType(swift::TargetContextDescriptor<swift::InProcess> const*, llvm::ArrayRef<swift::TargetMetadata<swift::InProcess> const*>, swift::TargetMetadata<swift::InProcess> const*) const + 257
    frame #6: 0x00007fff51340e7e libswiftCore.dylib`swift::Demangle::TypeDecoder<(anonymous namespace)::DecodedMetadataBuilder>::decodeMangledType(swift::Demangle::Node*) + 3726
    frame #7: 0x00007fff5133e32b libswiftCore.dylib`swift_getTypeByMangledNodeImpl(swift::MetadataRequest, swift::Demangle::Demangler&, swift::Demangle::Node*, void const* const*, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) + 411
    frame #8: 0x00007fff5133e132 libswiftCore.dylib`swift::swift_getTypeByMangledNode(swift::MetadataRequest, swift::Demangle::Demangler&, swift::Demangle::Node*, void const* const*, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) + 482
    frame #9: 0x00007fff5133e6bb libswiftCore.dylib`swift_getTypeByMangledNameImpl(swift::MetadataRequest, llvm::StringRef, void const* const*, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) + 779
    frame #10: 0x00007fff5133c1c2 libswiftCore.dylib`swift::swift_getTypeByMangledName(swift::MetadataRequest, llvm::StringRef, void const* const*, std::__1::function<swift::TargetMetadata<swift::InProcess> const* (unsigned int, unsigned int)>, std::__1::function<swift::TargetWitnessTable<swift::InProcess> const* (swift::TargetMetadata<swift::InProcess> const*, unsigned int)>) + 482
    frame #11: 0x00007fff51330d7a libswiftCore.dylib`getSuperclassMetadata(swift::TargetClassMetadata<swift::InProcess>*, bool) + 330
    frame #12: 0x00007fff5132b53b libswiftCore.dylib`_swift_initClassMetadataImpl(swift::TargetClassMetadata<swift::InProcess>*, swift::ClassLayoutFlags, unsigned long, swift::TypeLayout const* const*, unsigned long*, bool) + 43
    frame #13: 0x0000000106c0b905 Test`type metadata completion function for MergeBasicSink at <compiler-generated>:0
    frame #14: 0x00007fff51332ced libswiftCore.dylib`swift::MetadataCacheEntryBase<(anonymous namespace)::GenericCacheEntry, void const*>::doInitialization(swift::ConcurrencyControl&, swift::MetadataCompletionQueueEntry*, swift::MetadataRequest) + 285
    frame #15: 0x00007fff51329767 libswiftCore.dylib`swift_getGenericMetadata + 1527
    frame #16: 0x0000000106c0b4b0 Test`type metadata accessor for MergeBasicSink at <compiler-generated>:0
  * frame #17: 0x0000000106c09e24 Test`Merge.run<SourceSequence>(observer=0x0000600002b249c0, cancel=0x0000600002421260, self=0x0000600000f3cea0) at Merge.swift:580:20
    frame #18: 0x0000000106c2e535 Test`Producer.subscribe<Element>(observer=0x0000600002b249c0, self=0x0000600000f3cea0) at Producer.swift:18:44
    frame #19: 0x0000000106bfa690 Test`Map.run<SourceType>(observer=0x000060000017a640, cancel=0x0000600002420f50, self=0x000060000017a4f0) at Map.swift:99:41
    frame #20: 0x0000000106c2ee28 Test`closure #1 in Producer.subscribe<Element>(_0=() @ scalar, self=0x000060000017a4f0, observer=0x000060000017a640) at Producer.swift:26:48
    frame #21: 0x0000000106c2ef3c Test`partial apply for closure #1 in Producer.subscribe<A>(_:) at <compiler-generated>:0
    frame #22: 0x0000000106bcc1cc Test`thunk for @escaping @callee_guaranteed () -> (@out Disposable) at <compiler-generated>:0
    frame #23: 0x0000000106c2ef91 Test`partial apply for thunk for @escaping @callee_guaranteed () -> (@out Disposable) at <compiler-generated>:0
    frame #24: 0x0000000106bb875f Test`CurrentThreadScheduler.schedule<StateType>(state=() @ 0xffffffffffffffff, action=0x0000000106c2ef80 Test`partial apply forwarder for reabstraction thunk helper from @escaping @callee_guaranteed () -> (@out RxSwift.Disposable) to @escaping @callee_guaranteed (@in_guaranteed ()) -> (@out RxSwift.Disposable) at <compiler-generated>, self=0x0000600000d282b0) at CurrentThreadScheduler.swift:101:30
    frame #25: 0x0000000106c2e714 Test`Producer.subscribe<Element>(observer=0x000060000017a640, self=0x000060000017a4f0) at Producer.swift:24:52
    frame #26: 0x0000000106c1633d Test`ObservableType.subscribe(on=0x0000000106d122b0 Test`partial apply forwarder for closure #1 (RxSwift.Event<A.Element>) -> () in (extension in RxCocoa):RxSwift.ObservableType.(bind in _F14B11F29E4023218E8359F9EC4A42AD)<A where A1: RxSwift.ObserverType, A.Element == A1.Element>(to: Swift.Array<A1>) -> RxSwift.Disposable at <compiler-generated>, self=0x000060000017a4f0) at ObservableType+Extensions.swift:25:40
    frame #27: 0x0000000106d11983 Test`ObservableType.bind<Self>(observers=1 value, self=0x000060000017a4f0) at Observable+Bind.swift:42:21
    frame #28: 0x0000000106d118bd Test`ObservableType.bind<Self>(observers=1 value, self=0x000060000017a4f0) at Observable+Bind.swift:20:21
    frame #29: 0x0000000106b3dafc Test`AppDelegate.application(application=0x00007fcb08c00080, launchOptions=nil, self=0x0000600000d08150) at AppDelegate.swift:27:6
    frame #30: 0x0000000106b3e4b4 Test`@objc AppDelegate.application(_:didFinishLaunchingWithOptions:) at <compiler-generated>:0
    frame #31: 0x00007fff478467a8 UIKitCore`-[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 232
    frame #32: 0x00007fff478481b7 UIKitCore`-[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 3980
    frame #33: 0x00007fff4784dd06 UIKitCore`-[UIApplication _runWithMainScene:transitionContext:completion:] + 1281
    frame #34: 0x00007fff46f84422 UIKitCore`-[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 179
    frame #35: 0x00007fff4784a2a6 UIKitCore`-[UIApplication _compellApplicationLaunchToCompleteUnconditionally] + 59
    frame #36: 0x00007fff4784a5a5 UIKitCore`-[UIApplication _run] + 754
    frame #37: 0x00007fff4784fb68 UIKitCore`UIApplicationMain + 1621
    frame #38: 0x0000000106b3eaeb Test`main at AppDelegate.swift:14:7
    frame #39: 0x00007fff51a1dc25 libdyld.dylib`start + 1
    frame #40: 0x00007fff51a1dc25 libdyld.dylib`start + 1

Self contained code example that reproduces the issue:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    let aBinder = Binder<String>(self) { _, str in
      print(str)
    }

    _ = Observable.of(
      NotificationCenter.default.rx.notification(UIApplication.willResignActiveNotification),
      NotificationCenter.default.rx.notification(UIApplication.didBecomeActiveNotification)
    )
    .merge()
    .map { _ in "test" }
    .bind(to: aBinder)

    return true
}

Sample project is attached: Test.zip

RxSwift/RxCocoa/RxBlocking/RxTest version/commit

5.0.1

Platform/Environment

  • iOS
  • macOS
  • tvOS
  • watchOS
  • playgrounds

How easy is to reproduce? (chances of successful reproduce after running the self contained code)

  • easy, 100% repro
  • sometimes, 10%-100%
  • hard, 2% - 10%
  • extremely hard, %0 - 2%

Xcode version:

Version 11.2 (11B52)

Installation method:

  • SPM
  • CocoaPods
  • Carthage
  • Git submodules

I have multiple versions of Xcode installed:
(so we can know if this is a potential cause of your issue)

  • yes (which ones)
  • no

Level of RxSwift knowledge:
(this is so we can understand your level of knowledge
and formulate the response in an appropriate manner)

  • just starting
  • I have a small code base
  • I have a significant code base
@achernoprudov
Copy link

Related to #2094

@tcldr
Copy link

tcldr commented Nov 1, 2019

As mentioned in other issue thread – caused by SR-11564. (https://bugs.swift.org/browse/SR-11564)

@freak4pc
Copy link
Member

freak4pc commented Nov 1, 2019

🤦‍♂

@kzaher
Copy link
Member

kzaher commented Nov 1, 2019

Usually when somebody says

Xcode 11.2. Same code with 11.1 works fine.

that means it's not our bug :)

@RamblinWreck77
Copy link

RamblinWreck77 commented Nov 1, 2019

Temporary workaround that fixes it:

-Go to Project Target/Build Settings
-"Dead Code Stripping" to NO

@akolov
Copy link
Author

akolov commented Nov 2, 2019

Confirming that setting Dead Code Stripping to NO works. Otherwise crashes happen even when compiled with Xcode 11.1 after submitting to TestFlight.

@sree127
Copy link

sree127 commented Nov 4, 2019

I'm not able to run XCTests on Xcode 11.1,11.2 as it crashes from debounce with Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)

Screenshot 2019-11-04 at 16 24 11

Screenshot 2019-11-04 at 16 24 30

Dead Code Stripping is set to NO
Anyone else experiencing the same issue or any work around for this case? (It works in Xcode 10.3)

@brooksdubois
Copy link

Seeing this issue with a very simple code sample built using Carthage

Dead Code Stripping set to No

var updateString = BehaviorRelay<String>(value: "")

@IBOutlet weak var fetchButton: UIButton!
@IBOutlet weak var outputLabel: UILabel!

@IBAction func buttonTapped(_ sender: UIButton) {
  updateString.accept("Updated")
}
override func viewDidLoad() {
  super.viewDidLoad()
  updateString.bind(to: outputLabel.rx.text).disposed(by: disposeBag)
}

Crashes me immediately while initializing the Binder

@freak4pc
Copy link
Member

freak4pc commented Jan 5, 2020

Unfortunately this is a bug with SPM. People already filed a bug and I hope it would be fixed soon, but there's nothing much we can do as a framework.

@freak4pc freak4pc closed this as completed Jan 5, 2020
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

8 participants