Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

swift_isUniquelyReferenced_nonNull_native causes random and systematic crash on iOS 17.x

$
0
0

In my app, a crash occurs only on iOS 17.xx versions when I establish a BLE connection to a peripheral, scan wifi networks and connect to one of them via BLE.

private func writeData(writingMode: String) {        guard let discoveredPeripheral = discoveredPeripheral,                let transferCharacteristic = transferCharacteristic            else { return }        // check to see if number of iterations completed and peripheral can accept more data            let mtu = discoveredPeripheral.maximumWriteValueLength (for: .withoutResponse)            var rawPacket = [UInt8]()            if( self.connected && !self.wifiScanDone){                self.data.append(0x20)                self.data.append(0x04)                self.data.append(0x00)                self.data.append(0x00)                self.data.append(0x03)                self.data.append(0x47)                self.data.append(0x02)                self.data.append(0x10)                self.data.append(0x00)                self.data.append(0xff)                self.data.append(0xff)                self.data.append(0xff)                self.data.append(0xff)                self.data.append(0xff)                self.data.append(0xff)                self.data.append(0xff)                self.data.append(0xff)                self.data.append(0xff)                self.data.append(0xff)                self.data.append(0x56) }            else if (self.connected && self.wifiScanDone) {                self.data.append(0x20)                self.data.append(0x04)                self.data.append(0x00)                self.data.append(0x00)                self.data.append(0x03)                self.data.append(0x47)                self.data.append(0x03)                self.data.append(0x10)                self.data.append(0x00)                self.data.append(0xff)                self.data.append(0xff)                self.data.append(0xff)                self.data.append(0xff)                self.data.append(0xff)                self.data.append(0xff)                self.data.append(0xff)                self.data.append(0xff)                self.data.append(0xff)                self.data.append(0xff)                self.data.append(0x57)                }                print("writing data", String(describing: self.data))            let bytesToCopy: size_t = min(mtu, self.data.count)            self.data.copyBytes(to: &rawPacket, count: bytesToCopy)            var packetData = Data(bytes: &rawPacket, count: bytesToCopy)            let stringFromData = String(data: packetData, encoding: .utf8)            os_log("Writing %d bytes: %s", bytesToCopy, String(describing: stringFromData))            discoveredPeripheral.writeValue(packetData, for: transferCharacteristic, type: .withResponse)            packetData.removeAll()            self.data.removeAll()            discoveredPeripheral.setNotifyValue(true, for: transferCharacteristic)            self.writeIterationsComplete += 1        if writeIterationsComplete == defaultIterations {            // Cancel our subscription to the characteristic        }    }    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {        super.prepare(for: segue, sender: sender)        let wifiSelectionController = segue.destination as? WifiSelectionTestViewController        if segue.identifier == "skipSegue" {            if EcojokoHelper.isEcojokoV2() {                 wifiSelectionController?.wifiNetworksFromBle = wifiNetworks            }        }    }    private func writeDataScanDone() {        guard let discoveredPeripheral = discoveredPeripheral,              let transferCharacteristic = transferCharacteristic        else { return }        // check to see if number of iterations completed and peripheral can accept more data            let mtu = discoveredPeripheral.maximumWriteValueLength (for: .withResponse)            var rawPacket = [UInt8]()            self.data.append(0x20)            self.data.append(0x04)            self.data.append(0x00)            self.data.append(0x00)            self.data.append(0x03)            self.data.append(0x47)            self.data.append(0x03)            self.data.append(0x10)            self.data.append(0x00)            self.data.append(0xff)            self.data.append(0xff)            self.data.append(0xff)            self.data.append(0xff)            self.data.append(0xff)            self.data.append(0xff)            self.data.append(0xff)            self.data.append(0xff)            self.data.append(0xff)            self.data.append(0xff)            self.data.append(0x57)            let bytesToCopy: size_t = min(mtu, self.data.count)            self.data.copyBytes(to: &rawPacket, count: bytesToCopy)            var packetData = Data(bytes: &rawPacket, count: bytesToCopy)            let stringFromData = String(data: packetData, encoding: .utf8)            os_log("Writing  scan mode  %d bytes: %s", bytesToCopy, String(describing: stringFromData))            discoveredPeripheral.writeValue(packetData, for: transferCharacteristic, type: .withResponse)            packetData.removeAll()            self.data.removeAll()            discoveredPeripheral.setNotifyValue(true, for: transferCharacteristic)            self.writeIterationsComplete += 1            self.centralManager.cancelPeripheralConnection(discoveredPeripheral)            self.cleanup()            print("**** AT THIS POINT THE WIFI SCAN IS DONE ")            self.scanWritingData = true            if (self.connected && self.wifiScanDone && self.wifiNames.count == self.wifiCount &&  self.fillListDone) {                if let centralManager = self.centralManager {                    centralManager.stopScan()                    // os_log("Scanning stopped")                }                self.data.removeAll(keepingCapacity: false)            }    }    /*     *  If the connection fails for whatever reason, we need to deal with it.     */    func centralManager(_ central: CBCentralManager, didFailToConnect peripheral: CBPeripheral, error: Error?) {        os_log("Failed to connect to %@. %s", peripheral, String(describing: error))        cleanup()    }    /*     *  We've connected to the peripheral, now we need to discover the services and characteristics to find the 'transfer' characteristic.     */    func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {        if( !wifiListing)        {            print("**** BEFORE CONNECTION ***** The available peripherals are : \(String(describing: peripheral.services))")            os_log("Peripheral Connected")            self.connected = true            // Stop scanning            self.centralManager.stopScan()            os_log("Scanning stopped")            connectionIterationsComplete += 1            writeIterationsComplete = 0            // Clear the data that we may already have           // data.removeAll(keepingCapacity: false)            // Make sure we get the discovery callbacks            peripheral.delegate = self            // Search only for services that match our UUID            peripheral.discoverServices(nil)        }    }
# Crashlytics - Stack trace# Platform: apple# Version: 1.1 (1.9)# Issue: 412239cf1ac3c946eb36a0f8fcd03787# Session: 411b37f768814760898b918fa9d8c1b3_DNE_0_v2# Date: Wed Apr 17 2024 08:14:28 GMT+0200 (heure d’été d’Europe centrale)com.apple.main-thread0  libsystem_kernel.dylib         0x1af8 mach_msg2_trap + 81  libsystem_kernel.dylib         0x1890 mach_msg2_internal + 802  libsystem_kernel.dylib         0x17a8 mach_msg_overwrite + 4363  libsystem_kernel.dylib         0x15e8 mach_msg + 244  CoreFoundation                 0x3601c __CFRunLoopServiceMachPort + 1605  CoreFoundation                 0x33f04 __CFRunLoopRun + 12086  CoreFoundation                 0x33968 CFRunLoopRunSpecific + 6087  GraphicsServices               0x34e0 GSEventRunModal + 1648  UIKitCore                      0x22aedc -[UIApplication _run] + 8889  UIKitCore                      0x22a518 UIApplicationMain + 34010 Vattenfall                     0xb4ec main + 20 (AppDelegate.swift:20)11 ???                            0x1b33d6d84 (Manquant)com.apple.uikit.eventfetch-thread0  libsystem_kernel.dylib         0x1af8 mach_msg2_trap + 81  libsystem_kernel.dylib         0x1890 mach_msg2_internal + 802  libsystem_kernel.dylib         0x17a8 mach_msg_overwrite + 4363  libsystem_kernel.dylib         0x15e8 mach_msg + 244  CoreFoundation                 0x3601c __CFRunLoopServiceMachPort + 1605  CoreFoundation                 0x33f04 __CFRunLoopRun + 12086  CoreFoundation                 0x33968 CFRunLoopRunSpecific + 6087  Foundation                     0x2b4a8 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 2128  Foundation                     0x554e8 -[NSRunLoop(NSRunLoop) runUntilDate:] + 649  UIKitCore                      0x18dac8 -[UIEventFetcher threadMain] + 42010 Foundation                     0x9ca9c __NSThread__start__ + 73211 libsystem_pthread.dylib        0x2a90 _pthread_start + 13612 libsystem_pthread.dylib        0x1fcc thread_start + 8com.google.firebase.crashlytics.MachExceptionServer0  FirebaseCrashlytics            0x1ef18 FIRCLSProcessRecordAllThreads + 1841  FirebaseCrashlytics            0x1f2f8 FIRCLSProcessRecordAllThreads + 11762  FirebaseCrashlytics            0x16598 FIRCLSHandler + 483  FirebaseCrashlytics            0x18d58 FIRCLSMachExceptionServer + 6884  libsystem_pthread.dylib        0x2a90 _pthread_start + 1365  libsystem_pthread.dylib        0x1fcc thread_start + 8com.apple.NSURLConnectionLoader0  libsystem_kernel.dylib         0x1af8 mach_msg2_trap + 81  libsystem_kernel.dylib         0x1890 mach_msg2_internal + 802  libsystem_kernel.dylib         0x17a8 mach_msg_overwrite + 4363  libsystem_kernel.dylib         0x15e8 mach_msg + 244  CoreFoundation                 0x3601c __CFRunLoopServiceMachPort + 1605  CoreFoundation                 0x33f04 __CFRunLoopRun + 12086  CoreFoundation                 0x33968 CFRunLoopRunSpecific + 6087  CFNetwork                      0x25ac48 estimatedPropertyListSize + 382288  Foundation                     0x9ca9c __NSThread__start__ + 7329  libsystem_pthread.dylib        0x2a90 _pthread_start + 13610 libsystem_pthread.dylib        0x1fcc thread_start + 8Thread0  libsystem_kernel.dylib         0xa084 __workq_kernreturn + 81  libsystem_pthread.dylib        0x1f6c _pthread_wqthread + 3642  libsystem_pthread.dylib        0x1fc0 start_wqthread + 8Crashed: ZuluCalendar0  libswiftCore.dylib             0x4065e4 swift_isUniquelyReferenced_nonNull_native + 481  Foundation                     0x2e75c specialized Set._Variant.insert(_:) + 2042  Foundation                     0x2e8de4 _fromNSCalendarUnits(_:) + 1763  Foundation                     0x2e410 _NSSwiftCalendar._components(_:from:) + 604  Foundation                     0x2e274 @objc _NSSwiftCalendar._components(_:from:) + 805  CoreFoundation                 0xc4e08 CFCalendarDecomposeAbsoluteTime + 3486  Security                       0x11df64 __SecAbsoluteTimeGetGregorianDate_block_invoke + 647  libdispatch.dylib              0x3dd4 _dispatch_client_callout + 208  libdispatch.dylib              0x132c4 _dispatch_lane_barrier_sync_invoke_and_complete + 569  Security                       0xaf0c SecCFCalendarDoWithZuluCalendar + 12810 Security                       0x7ad4 der_encode_generalizedtime_body_repair + 23211 Security                       0x76ac der_encode_plist_repair + 46812 Security                       0x7560 der_encode_plist_repair + 13613 Security                       0x7560 der_encode_plist_repair + 13614 Security                       0x740c add_sequence_to_array + 13615 CoreFoundation                 0x2507c -[__NSDictionaryM __apply:context:] + 12816 Security                       0x13b80 der_encode_dictionary_repair + 12417 Security                       0x740c add_sequence_to_array + 13618 CoreFoundation                 0x2507c -[__NSDictionaryM __apply:context:] + 12819 Security                       0x13b80 der_encode_dictionary_repair + 12420 Security                       0x7560 der_encode_plist_repair + 13621 Security                       0x740c add_sequence_to_array + 13622 CoreFoundation                 0x2507c -[__NSDictionaryM __apply:context:] + 12823 Security                       0x13b80 der_encode_dictionary_repair + 12424 Security                       0xcc2c CFPropertyListCreateDERData + 10025 Security                       0xcb78 SecTrustSerialize + 21626 CFNetwork                      0x1ef68 _CFNetworkSetHSTSStoragePath + 9361227 CFNetwork                      0xab3ac CFURLDownloadStart + 7476828 CFNetwork                      0xaaedc CFURLDownloadStart + 7353629 CFNetwork                      0xbc780 CFURLDownloadStart + 14538030 CFNetwork                      0x1da190 CFHTTPCookieStorageUnscheduleFromRunLoop + 15891631 CFNetwork                      0xbaa64 CFURLDownloadStart + 13792832 libboringssl.dylib             0x3b638 __boringssl_context_evaluate_trust_async_external_block_invoke + 44833 libdispatch.dylib              0x213c _dispatch_call_block_and_release + 3234 libdispatch.dylib              0x3dd4 _dispatch_client_callout + 2035 libdispatch.dylib              0xb400 _dispatch_lane_serial_drain + 74836 libdispatch.dylib              0xbf64 _dispatch_lane_invoke + 43237 libdispatch.dylib              0xd284 _dispatch_workloop_invoke + 175638 libdispatch.dylib              0x16cb4 _dispatch_root_queue_drain_deferred_wlh + 28839 libdispatch.dylib              0x16528 _dispatch_workloop_worker_thread + 40440 libsystem_pthread.dylib        0x1f20 _pthread_wqthread + 28841 libsystem_pthread.dylib        0x1fc0 start_wqthread + 8

First, the code establishes a BLE connection to a specific peripheral, when he finds the right services and characteristics, it connects to them and asks the device to do a wifi scan. Then, the device searches for nearby wifi networks and sends the list to the app. The user selects one of the listed networks, fills the password and sends a connection request to the BLE peripheral.Here is the crash's stacktrace from Crashlytics. I'd like to get some help resolving the crash:Sample code of BLE Exchange source code: (can't provide full source code due to security and privacy compliance) :


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>