Long stack trace ending with a SIGBUS in libSwiftCore getCache()

I have a (ReactiveSwift) timer running indefinitely that fires every x minutes. After ~6 days and having accumulated about 500 stack frames, the iOS application crashes with the following few stack frames:

0   libswiftCore.dylib                   0x0000000191876178 getCache(swift::TargetTypeContextDescriptor<swift::InProcess> const&) + 8
1   LLLLLLLL                             0x0000000100d62208 __swift_instantiateGenericMetadata (<compiler-generated>:0)
2   LLLLLLLL                             0x0000000100d9f338 ReactiveSwift.Signal.(Core in _6DF632AE8A9288C3EAD8EFDF3D3AF99E).send(ReactiveSwift.Signal<A, B>.Event) -> () (<compiler-generated>:0)
3   LLLLLLLL                             0x0000000100d9e364 ReactiveSwift.Signal.Observer.send(ReactiveSwift.Signal<A, B>.Event) -> () (Signal.Observer.swift:111)
4   LLLLLLLL                             0x0000000100d7ca80 generic partial specialization <Signature = @escaping @convention(thin) @convention(method) <A, B><A1 where B: Swift.Error, A1 == ReactiveSwift.Lock> (@in_guaranteed ReactiveSwift.Signal<A, B>.Event, @guaranteed ReactiveSwift.Signal<A, B>.(Core in _6DF632AE8A9288C3EAD8EFDF3D3AF99E)<ReactiveSwift.Lock>) -> ()> of ReactiveSwift.Signal.(Core in _6DF632AE8A9288C3EAD8EFDF3D3AF99E).send(ReactiveSwift.Signal<A, B>.Event) -> () (Signal.swift:124)

The stack frames from 5 to 511 are repetitions of the following:

5   LLLLLLLL                            0x0000000100d9e364 ReactiveSwift.Signal.Observer.send(ReactiveSwift.Signal<A, B>.Event) -> () (Signal.Observer.swift:111)
6   LLLLLLLL                            0x0000000100d760b8 closure #3 (ReactiveSwift.Signal<A.Value, B>.Event) -> () in closure #1 (ReactiveSwift.Signal<A.Value, B>, ReactiveSwift.Disposable) -> () in closure #1 (ReactiveSwift.Signal<A, B>.Event) -> () in (extension in ReactiveSwift):ReactiveSwift.Signal< where A: ReactiveSwift.SignalProducerConvertible, B == A.Error>.(observeSwitchToLatest in _6345D8752C3E65AA1118F4C784F9873D)(ReactiveSwift.Signal<A.Value, B>.Observer, ReactiveSwift.SerialDisposable) -> ReactiveSwift.Disposable? (Flatten.swift:677)

Note that the app has been running for 6 days until the crash occurs.

Crash details are as follows:

Exception Type:  SIGBUS
Exception Codes: BUS_ADRERR at 0x16f4a3f90
Crashed Thread:  0

Could this be a Swift runtime bug that causes the cache to get corrupted?

Try changing x minutes to, say, 0.0 second1 to see if it'll crash quickly.

Thank you. It seems to be an infinite recursion. Can't reproduce it so far, and not all users report it. I have identified suspicious code and will rewrite it to break any potential circular dependencies between the signals.

One of the easiest things to check: assuming the structure is used from the main thread and unprotected, make sure it is not called accidentally from another thread:

dispatchPrecondition(condition: .onQueue(.main))
... access the structure