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)
``* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x00007fff5132ba49 libswiftCore.dylib_swift_initClassMetadataImpl(swift::TargetClassMetadata
frame #1: 0x0000000106c0bc46 Testtype metadata completion function for MergeSink at <compiler-generated>:0
frame #2: 0x00007fff51332ced libswiftCore.dylibswift::MetadataCacheEntryBase<(anonymous namespace)::GenericCacheEntry, void const>::doInitialization(swift::ConcurrencyControl&, swift::MetadataCompletionQueueEntry, swift::MetadataRequest) + 285
frame #3: 0x00007fff51329767 libswiftCore.dylibswift_getGenericMetadata + 1527
frame #4: 0x0000000106c0bc90 Testtype metadata accessor for MergeSink at
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.dylibswift::Demangle::TypeDecoder<(anonymous namespace)::DecodedMetadataBuilder>::decodeMangledType(swift::Demangle::Node) + 3726
frame #7: 0x00007fff5133e32b libswiftCore.dylibswift_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.dylibswift::swift_getTypeByMangledNode(swift::MetadataRequest, swift::Demangle::Demangler&, swift::Demangle::Node, void const* const, std::__1::function
frame #9: 0x00007fff5133e6bb libswiftCore.dylibswift_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.dylibswift::swift_getTypeByMangledName(swift::MetadataRequest, llvm::StringRef, void const const, std::__1::function
frame #11: 0x00007fff51330d7a libswiftCore.dylibgetSuperclassMetadata(swift::TargetClassMetadata<swift::InProcess>*, bool) + 330
frame #12: 0x00007fff5132b53b libswiftCore.dylib_swift_initClassMetadataImpl(swift::TargetClassMetadata
frame #13: 0x0000000106c0b905 Testtype metadata completion function for MergeBasicSink at <compiler-generated>:0
frame #14: 0x00007fff51332ced libswiftCore.dylibswift::MetadataCacheEntryBase<(anonymous namespace)::GenericCacheEntry, void const>::doInitialization(swift::ConcurrencyControl&, swift::MetadataCompletionQueueEntry, swift::MetadataRequest) + 285
frame #15: 0x00007fff51329767 libswiftCore.dylibswift_getGenericMetadata + 1527
frame #16: 0x0000000106c0b4b0 Testtype metadata accessor for MergeBasicSink at
Merge.run<SourceSequence>(observer=0x0000600002b249c0, cancel=0x0000600002421260, self=0x0000600000f3cea0) at Merge.swift:580:20
frame #18: 0x0000000106c2e535 TestProducer.subscribeMap.run<SourceType>(observer=0x000060000017a640, cancel=0x0000600002420f50, self=0x000060000017a4f0) at Map.swift:99:41
frame #20: 0x0000000106c2ee28 Testclosure #1 in Producer.subscribepartial apply for closure #1 in Producer.subscribe<A>(_:) at <compiler-generated>:0
frame #22: 0x0000000106bcc1cc Testthunk for @escaping @callee_guaranteed () -> (@out Disposable) at partial apply for thunk for @escaping @callee_guaranteed () -> (@out Disposable) at <compiler-generated>:0
frame #24: 0x0000000106bb875f TestCurrentThreadScheduler.schedulepartial 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 TestProducer.subscribeObservableType.subscribe(on=0x0000000106d122b0 Testpartial apply forwarder for closure #1 (RxSwift.EventObservableType.bind<Self>(observers=1 value, self=0x000060000017a4f0) at Observable+Bind.swift:42:21
frame #28: 0x0000000106d118bd TestObservableType.bindAppDelegate.application(application=0x00007fcb08c00080, launchOptions=nil, self=0x0000600000d08150) at AppDelegate.swift:27:6
frame #30: 0x0000000106b3e4b4 Test@objc AppDelegate.application(_:didFinishLaunchingWithOptions:) at -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 232
frame #32: 0x00007fff478481b7 UIKitCore-[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 3980-[UIApplication _runWithMainScene:transitionContext:completion:] + 1281
frame #34: 0x00007fff46f84422 UIKitCore-[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 179-[UIApplication _compellApplicationLaunchToCompleteUnconditionally] + 59
frame #36: 0x00007fff4784a5a5 UIKitCore-[UIApplication _run] + 754UIApplicationMain + 1621
frame #38: 0x0000000106b3eaeb Testmain at AppDelegate.swift:14:7start + 1
frame #40: 0x00007fff51a1dc25 libdyld.dylibstart + 1**Self contained code example that reproduces the issue**:
```swift
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
How easy is to reproduce? (chances of successful reproduce after running the self contained code)
Xcode version:
Version 11.2 (11B52)
Installation method:
I have multiple versions of Xcode installed:
(so we can know if this is a potential cause of your issue)
Level of RxSwift knowledge:
(this is so we can understand your level of knowledge
and formulate the response in an appropriate manner)
Related to #2094
As mentioned in other issue thread 鈥撀燾aused by SR-11564. (https://bugs.swift.org/browse/SR-11564)
馃う鈥嶁檪
Usually when somebody says
Xcode 11.2. Same code with 11.1 works fine.
that means it's not our bug :)
Temporary workaround that fixes it:
-Go to Project Target/Build Settings
-"Dead Code Stripping" to NO
Confirming that setting Dead Code Stripping to NO works. Otherwise crashes happen even when compiled with Xcode 11.1 after submitting to TestFlight.
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)


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)
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
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.
Most helpful comment
Temporary workaround that fixes it:
-Go to Project Target/Build Settings
-"Dead Code Stripping" to NO