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

Bringing app to foreground crash #33

Open
paulotaylor opened this issue Jun 24, 2021 · 5 comments
Open

Bringing app to foreground crash #33

paulotaylor opened this issue Jun 24, 2021 · 5 comments

Comments

@paulotaylor
Copy link

I'm wondering if you had this issue before, maybe I'm doing something wrong. It crashes when bringing up the app to foreground after being in the background for a while and setting handleBackgroundTransitions = true

Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000121bec008
Crashed: com.apple.main-thread
0 libswiftCore.dylib 0x192f1162c swift_release + 44
1 libswiftCore.dylib 0x192bac8a8 Array.makeUniqueAndReserveCapacityIfNotUnique() + 212
2 libswiftCore.dylib 0x192bacac8 Array.append(
:) + 40
3 MyApp 0x100cd8984 SwiftyPing.informObserver(of:) + 435 (SwiftyPing.swift:435)
4 MyApp 0x100cdaa1c SwiftyPing.socket(socket:didReadData:) + 571 (SwiftyPing.swift:571)
5 MyApp 0x100cd6558 closure #1 in closure #1 in SwiftyPing.createSocket() + 281 (SwiftyPing.swift:281)
6 MyApp 0x100cd660c @objc closure #1 in closure #1 in SwiftyPing.createSocket() + 84 (:84)
7 CoreFoundation 0x18efb78dc __CFSocketPerformV0 + 812
8 CoreFoundation 0x18efac9e8 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 28
9 CoreFoundation 0x18efac8e4 __CFRunLoopDoSource0 + 208
10 CoreFoundation 0x18efabbe8 __CFRunLoopDoSources0 + 268
11 CoreFoundation 0x18efa5bc8 __CFRunLoopRun + 820
12 CoreFoundation 0x18efa5360 CFRunLoopRunSpecific + 600
13 GraphicsServices 0x1a65e3734 GSEventRunModal + 164
14 UIKitCore 0x191a20584 -[UIApplication _run] + 1072
15 UIKitCore 0x191a25df4 UIApplicationMain + 168
16 MyApp 0x100c7b7ec main + 34 (AppDelegate.swift:34)
17 libdyld.dylib 0x18ec61cf8 start + 4

@mumuWorld
Copy link

I have the same problem but not in main-thread. It occurs above iOS 15.0, last func Stack maybe in
private func informObserver(of response: PingResponse) {

Thread 13 Crashed:
0 libsystem_platform.dylib 0x00000001f0d5cab0 platform_memmove
1 MyApp 0x00000001055708c8 $sSa16_createNewBuffer14bufferIsUnique15minimumCapacity13growForAppendySb_SiSbtF5YDASR12PingResponseV_Tg5 + [ : 0]
2 MyApp 0x0000000105568db8 $s5YDASR10SwiftyPingC14informObserver33_5A2F9010047290E81DA28B78E947473ALL2ofyAA0C8ResponseV_tF + [ : 0]
3 MyApp 0x00000001055685a8 $s5YDASR10SwiftyPingC04sendC033_5A2F9010047290E81DA28B78E947473ALLyyFyycfU

4 MyApp 0x0000000104e0e524 $sIeg_IeyB_TR + [ : 0]
5 libdispatch.dylib 0x0000000180598c04 _dispatch_call_block_and_release
6 libdispatch.dylib 0x000000018059a950 _dispatch_client_callout
7 libdispatch.dylib 0x00000001805a20ac _dispatch_lane_serial_drain
8 libdispatch.dylib 0x00000001805a2c10 _dispatch_lane_invoke
9 libdispatch.dylib 0x00000001805ad318 _dispatch_workloop_worker_thread
10 libsystem_pthread.dylib 0x00000001f0d651b0 _pthread_wqthread

@RobbieElias
Copy link

I'm having the same issue as well

@iosdec
Copy link

iosdec commented May 17, 2022

Also having this issue, anybody solve this?

@jamestapping
Copy link

jamestapping commented Jun 28, 2022

I had a crash when coming to foreground, possibly to do with resolving an address.

public static func getIPv4AddressFromHost(host: String) throws -> Data {
var streamError = CFStreamError()
let cfhost = CFHostCreateWithName(nil, host as CFString).takeRetainedValue()
let status = CFHostStartInfoResolution(cfhost, .addresses, &streamError)

I'll change the hostname to an IP and report back.

@SerhiienkoOleksii
Copy link

SerhiienkoOleksii commented Jan 31, 2024

I had a same issue and was able to solve it by making:

public private(set) var responses: [PingResponse] = []

and

private var erroredIndices = [Int]()

threadsafe.
These two arrays are used from different threads which is a reason of that crash.
You can try to replace them with:

private var _responses: [PingResponse] = []
public private(set) var responses: [PingResponse] {
    get {
        _serial_property.sync { self._responses }
    }
    set {
        _serial_property.sync { self._responses = newValue }
    }
}

and

private var _erroredIndices = [Int]()
private var erroredIndices: [Int] {
    get {
        _serial_property.sync { self._erroredIndices }
    }
    set {
        _serial_property.sync { self._erroredIndices = newValue }
    }
}

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

6 participants