Skip to content

[Bug] connectivity_plus iOS Crash: swift::fatalError in NWPathMonitor (race condition) #3753

@manuel-goester-n41

Description

@manuel-goester-n41

Description

Firebase Crashlytics reported a fatal crash on iOS originating from connectivity_plus.

The stack trace indicates a memory corruption issue (swift::fatalError / swift_deallocPartialClassInstance) occurring within NWPathMonitor. This appears to be caused by a race condition where network updates are processed on a concurrent background queue while the monitor is being deallocated.

Stack Trace

Crashed: com.apple.root.utility-qos
0  libsystem_kernel.dylib         0x7198 __pthread_kill + 8
1  libsystem_pthread.dylib        0xd5f8 pthread_kill + 208
2  libsystem_c.dylib              0x1c4b8 abort + 124
3  libswiftCore.dylib             0x2f2998 swift::fatalError(unsigned int, char const*, ...) + 130
4  libswiftCore.dylib             0x2f29b4 swift::warningv(unsigned int, char const*, char*) + 26
5  libswiftCore.dylib             0x2f72ec swift_deallocPartialClassInstance + 170
6  libswiftCore.dylib             0x2f7184 _swift_release_dealloc + 28
7  libswiftCore.dylib             0x2f8060 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1>>::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 184
8  libswiftNetwork.dylib          0x32794 assignWithTake for NWPath + 64
9  libswiftNetwork.dylib          0x32f28 outlined assign with take of NWPath + 52
10 libswiftNetwork.dylib          0x30400 closure #1 in NWPathMonitor.init(_:) + 144
11 libswiftNetwork.dylib          0x307a8 partial apply for closure #1 in NWPathMonitor.init(requiredInterfaceType:) + 16
12 libswiftNetwork.dylib          0x166a8 thunk for @escaping @callee_guaranteed (@guaranteed OS_nw_path) -> () + 44
13 Network                        0x7d1918 __nw_path_necp_update_evaluator_block_invoke + 448
14 libdispatch.dylib              0x637a8 _dispatch_call_block_and_release + 24
15 libdispatch.dylib              0x64780 _dispatch_client_callout + 16
16 libdispatch.dylib              0x48d88 _dispatch_root_queue_drain + 616
17 libdispatch.dylib              0x49430 _dispatch_worker_thread2 + 160
18 libsystem_pthread.dylib        0x1b94 _pthread_wqthread + 224
19 libsystem_pthread.dylib        0x1720 start_wqthread + 8

Environment

  • Plugin: connectivity_plus
  • OS Version: iOS 16.7.12
  • Device: iPhone 8

Fix

A fix has been proposed in PR #3752 which moves the NWPathMonitor to a serial queue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions