Приложение упало из-за EXC_BREAKPOINT (SIGTRAP) - PullRequest
0 голосов
/ 11 марта 2020

один из тестеров моего приложения сообщил об этом взломщике sh. Я просто не могу понять, что является причиной этого кр sh. вот журнал cra sh:

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001027f6bf0
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating Process: exc handler [1054]
Triggered by Thread:  0

Thread 0 name:
Thread 0 Crashed:
0   App Names           0x00000001027f6bf0 UpcomingViewController.networkCall1() + 4420 (UpcomingViewController.swift:240)
1   App Names           0x00000001027f88ec @objc UpcomingViewController.networkCall1() + 28 (<compiler-generated>:0)
2   CoreFoundation                  0x00000001913e2360 __CFFireTimer + 64 (CFObject.m:1573)
3   CoreFoundation                  0x0000000191366dcc -[__NSCFTimer fire] + 88 (CFObject.m:1604)
4   App Names           0x00000001027f5a9c @objc UpcomingViewController.scheduledTimerWithTimeInterval1() + 28 (<compiler-generated>:0)
5   CoreFoundation                  0x00000001913da288 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20 (CFNotificationCenter.c:787)
6   CoreFoundation                  0x00000001913da2d0 ___CFXRegistrationPost1_block_invoke + 64 (CFNotificationCenter.c:175)
7   CoreFoundation                  0x00000001913d9630 _CFXRegistrationPost1 + 368 (CFNotificationCenter.c:198)
8   CoreFoundation                  0x00000001913d92e8 ___CFXNotificationPost_block_invoke + 104 (CFNotificationCenter.c:1371)
9   CoreFoundation                  0x000000019135559c -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1416 (CFXNotificationRegistrarOld.m:168)
10  CoreFoundation                  0x00000001913d8c38 _CFXNotificationPost + 1244 (CFNotificationCenter.c:1359)
11  Foundation                      0x00000001917350c8 -[NSNotificationCenter postNotificationName:object:userInfo:] + 60 (NSNotification.m:576)
12  UIKitCore                       0x000000019551a2a4 -[UIApplication _sendWillEnterForegroundCallbacks] + 280 (UIApplication.m:10519)
13  UIKitCore                       0x0000000194cd0450 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransiti... + 1732 (_UISceneLifecycleMultiplexer.m:572)
14  UIKitCore                       0x0000000195165698 _UIScenePerformActionsWithLifecycleActionMask + 100 (_UISceneLifecycleState.m:109)
15  UIKitCore                       0x0000000194ccfcf0 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransiti... + 196 (_UISceneLifecycleMultiplexer.m:501)
16  UIKitCore                       0x0000000194ccf748 -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 296 (_UISceneLifecycleMultiplexer.m:450)
17  UIKitCore                       0x0000000194ccfb1c -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionSto... + 736 (_UISceneLifecycleMultiplexer.m:500)
18  UIKitCore                       0x0000000194ccf3d8 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 336 (_UISceneLifecycleMultiplexer.m:406)
19  UIKitCore                       0x0000000194cd38c4 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsFo... + 188 (_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction.m:102)
20  UIKitCore                       0x0000000195096f08 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] + 824 (BSAnimationSettings+UIKit.m:50)
21  UIKitCore                       0x000000019517ec84 _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 244 (_UISceneSettingsDiffAction.m:43)
22  UIKitCore                       0x0000000194cd35fc __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsFo... + 136 (_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction.m:87)
23  UIKitCore                       0x000000019517eb80 _UISceneSettingsDiffActionPerformActionsWithDelayForTransitionContext + 100 (_UISceneSettingsDiffAction.m:35)
24  UIKitCore                       0x0000000194cd3468 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUISc... + 376 (_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction.m:85)
25  UIKitCore                       0x0000000194b452c0 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 636 (UIScene.m:1338)
26  UIKitCore                       0x0000000194b43e28 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 248 (UIScene.m:1071)
27  UIKitCore                       0x0000000194b44ff8 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 220 (UIScene.m:1315)
28  UIKitCore                       0x00000001950b7d70 -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 464 (UIApplicationSceneClientAgent.m:80)
29  FrontBoardServices              0x00000001965b2248 -[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:] + 544 (FBSSceneImpl.m:551)
30  FrontBoardServices              0x00000001965d6d28 __88-[FBSWorkspaceScenesClient sceneID:updateWithSettingsDiff:transitionContext:completion:]_bloc... + 120 (FBSWorkspaceScenesClient.m:356)
31  FrontBoardServices              0x00000001965bbf04 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 232 (FBSWorkspace.m:357)
32  FrontBoardServices              0x00000001965d6c5c __88-[FBSWorkspaceScenesClient sceneID:updateWithSettingsDiff:transitionContext:completion:]_bloc... + 184 (FBSWorkspaceScenesClient.m:355)
33  libdispatch.dylib               0x000000019114b184 _dispatch_client_callout + 16 (object.m:495)
34  libdispatch.dylib               0x00000001910f3fd8 _dispatch_block_invoke_direct$VARIANT$mp + 224 (queue.c:466)
35  FrontBoardServices              0x00000001965fb418 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 40 (FBSSerialQueue.m:173)
36  FrontBoardServices              0x00000001965fb0e4 -[FBSSerialQueue _queue_performNextIfPossible] + 404 (FBSSerialQueue.m:216)
37  FrontBoardServices              0x00000001965fb60c -[FBSSerialQueue _performNextFromRunLoopSource] + 28 (FBSSerialQueue.m:247)
38  CoreFoundation                  0x00000001913fca00 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 (CFRunLoop.c:1922)
39  CoreFoundation                  0x00000001913fc958 __CFRunLoopDoSource0 + 80 (CFRunLoop.c:1956)
40  CoreFoundation                  0x00000001913fc0f0 __CFRunLoopDoSources0 + 180 (CFRunLoop.c:1992)
41  CoreFoundation                  0x00000001913f723c __CFRunLoopRun + 1080 (CFRunLoop.c:2882)
42  CoreFoundation                  0x00000001913f6adc CFRunLoopRunSpecific + 464 (CFRunLoop.c:3192)
43  GraphicsServices                0x000000019b397328 GSEventRunModal + 104 (GSEvent.c:2246)
44  UIKitCore                       0x000000019550463c UIApplicationMain + 1936 (UIApplication.m:4773)
45  App Names           0x00000001027c0b3c main + 68 (SlideOutTransition.swift:15)
46  libdyld.dylib                   0x0000000191280360 start + 4

Thread 1 name:
Thread 1:
0   libsystem_kernel.dylib          0x0000000191254634 mach_msg_trap + 8
1   libsystem_kernel.dylib          0x0000000191253aa0 mach_msg + 72 (mach_msg.c:103)
2   CoreFoundation                  0x00000001913fc288 __CFRunLoopServiceMachPort + 216 (CFRunLoop.c:2575)
3   CoreFoundation                  0x00000001913f73a8 __CFRunLoopRun + 1444 (CFRunLoop.c:2931)
4   CoreFoundation                  0x00000001913f6adc CFRunLoopRunSpecific + 464 (CFRunLoop.c:3192)
5   Foundation                      0x0000000191736784 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 228 (NSRunLoop.m:374)
6   Foundation                      0x0000000191736664 -[NSRunLoop(NSRunLoop) runUntilDate:] + 88 (NSRunLoop.m:421)
7   UIKitCore                       0x000000019559ce80 -[UIEventFetcher threadMain] + 152 (UIEventFetcher.m:637)
8   Foundation                      0x000000019186709c __NSThread__start__ + 848 (NSThread.m:724)
9   libsystem_pthread.dylib         0x0000000191199d8c _pthread_start + 156 (pthread.c:896)
10  libsystem_pthread.dylib         0x000000019119d76c thread_start + 8

Thread 2 name:
Thread 2:
0   libsystem_kernel.dylib          0x0000000191254634 mach_msg_trap + 8
1   libsystem_kernel.dylib          0x0000000191253aa0 mach_msg + 72 (mach_msg.c:103)
2   CoreFoundation                  0x00000001913fc288 __CFRunLoopServiceMachPort + 216 (CFRunLoop.c:2575)
3   CoreFoundation                  0x00000001913f73a8 __CFRunLoopRun + 1444 (CFRunLoop.c:2931)
4   CoreFoundation                  0x00000001913f6adc CFRunLoopRunSpecific + 464 (CFRunLoop.c:3192)
5   CFNetwork                       0x00000001946c04e8 -[__CoreSchedulingSetRunnable runForever] + 192 (CoreSchedulingSet.mm:1372)
6   Foundation                      0x000000019186709c __NSThread__start__ + 848 (NSThread.m:724)
7   libsystem_pthread.dylib         0x0000000191199d8c _pthread_start + 156 (pthread.c:896)
8   libsystem_pthread.dylib         0x000000019119d76c thread_start + 8

Thread 3 name:
Thread 3:
0   libsystem_kernel.dylib          0x0000000191254634 mach_msg_trap + 8
1   libsystem_kernel.dylib          0x0000000191253aa0 mach_msg + 72 (mach_msg.c:103)
2   CoreFoundation                  0x00000001913fc288 __CFRunLoopServiceMachPort + 216 (CFRunLoop.c:2575)
3   CoreFoundation                  0x00000001913f73a8 __CFRunLoopRun + 1444 (CFRunLoop.c:2931)
4   CoreFoundation                  0x00000001913f6adc CFRunLoopRunSpecific + 464 (CFRunLoop.c:3192)
5   AVFAudio                        0x000000019dfd9c1c GenericRunLoopThread::Entry(void*) + 156 (GenericRunLoopThread.h:91)
6   AVFAudio                        0x000000019e02ad60 CAPThread::Entry(CAPThread*) + 204 (CAPThread.cpp:286)
7   libsystem_pthread.dylib         0x0000000191199d8c _pthread_start + 156 (pthread.c:896)
8   libsystem_pthread.dylib         0x000000019119d76c thread_start + 8

Thread 4:
0   libsystem_pthread.dylib         0x000000019119d758 start_wqthread + 0

Thread 5:
0   libsystem_pthread.dylib         0x000000019119d758 start_wqthread + 0

Thread 6:
0   libsystem_pthread.dylib         0x000000019119d758 start_wqthread + 0

Thread 7 name:
Thread 7:
0   libsystem_kernel.dylib          0x00000001912779f4 kevent_id + 8
1   libdispatch.dylib               0x000000019110de18 _dispatch_kq_poll + 332 (event_kevent.c:750)
2   libdispatch.dylib               0x000000019110d920 _dispatch_kq_drain + 124 (event_kevent.c:809)
3   libdispatch.dylib               0x000000019110d844 _dispatch_event_loop_drain$VARIANT$mp + 316 (event_kevent.c:1965)
4   libdispatch.dylib               0x00000001910f8e28 _dispatch_workloop_invoke$VARIANT$mp + 1456 (queue.c:4270)
5   libdispatch.dylib               0x0000000191101314 _dispatch_workloop_worker_thread + 588 (queue.c:6445)
6   libsystem_pthread.dylib         0x000000019119ab88 _pthread_wqthread + 276 (pthread.c:2351)
7   libsystem_pthread.dylib         0x000000019119d760 start_wqthread + 8

Thread 8:
0   libsystem_pthread.dylib         0x000000019119d758 start_wqthread + 0

Thread 9:
0   libsystem_pthread.dylib         0x000000019119d758 start_wqthread + 0

Thread 10:
0   libsystem_pthread.dylib         0x000000019119d758 start_wqthread + 0

Thread 11:
0   libsystem_pthread.dylib         0x000000019119d758 start_wqthread + 0

Thread 12:
0   libsystem_pthread.dylib         0x000000019119d758 start_wqthread + 0

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x00000002811a05d0   x1: 0x00000001c97fd320   x2: 0x0000000000000000   x3: 0x000000000000000b
    x4: 0x000000000000000b   x5: 0x0000000000000010   x6: 0x000000000000006e   x7: 0x0000000000000000
    x8: 0x6012e6b213e200eb   x9: 0x6012e6b213e200eb  x10: 0x000021a1d9f09259  x11: 0x001f000102e70ce0
   x12: 0x0000000102e70ce0  x13: 0x000041a1d9f09259  x14: 0x0000000075cda64e  x15: 0x0000000000000065
   x16: 0x00000001d9f03258  x17: 0x00000001911a1904  x18: 0x0000000000000000  x19: 0x0000000000000000
   x20: 0x000000016d640f60  x21: 0x00000001d9f09258  x22: 0x00000002811a05d0  x23: 0x9de4111954e7fd89
   x24: 0x0000000102990000  x25: 0x0000000000000001  x26: 0x000000016d640f30  x27: 0x000000016d640f20
   x28: 0x0000000102990000   fp: 0x000000016d641130   lr: 0x00000001027f6438
    sp: 0x000000016d640ea0   pc: 0x00000001027f6bf0 cpsr: 0x60000000
   esr: 0xf2000001  Address size fault

это функция networCall1 (), которая, я думаю, вызвала ее, но я не знаю, где

@objc func networkCall1() {
 var dd:Date
        var StartDate=""
        if let date=Calendar.current.date(byAdding: .month , value: +1, to: Date()){
            dd=Calendar.current.date(byAdding: .day, value:-1, to: date)!
         StartDate=dd.convertDatetoString(format: "yyyy-MM-dd'T'HH:mm:ss")
        }
        let EndDate=Date().convertDatetoString(format: "yyyy-MM-dd'T'HH:mm:ss")
        let session = URLSession.shared
          let string="api call"
          let urlC = URL(string: string)
          guard let url = urlC else {
              print("url fail")
            return
          }
          var request = URLRequest(url: url)
          request.httpMethod = "POST"
          request.setValue("application/json", forHTTPHeaderField: "Content-Type")
        request.setValue("Bearer \(UserDefaults.standard.object(forKey: "token") as! String)", forHTTPHeaderField: "Authorization")
          let json=[
              "StartDate": EndDate,
              "EndDate": StartDate,
              "SubstituteId": UserDefaults.standard.object(forKey: "userId"),
              "OrganizationId": UserDefaults.standard.object(forKey: "organizationId"),
              "DistrictId": UserDefaults.standard.object(forKey: "districtId"),
              "Status": 2,
              "Requested": false
            ] as [String : Any?]
          do {
              let jsonData = try JSONSerialization.data(withJSONObject: json, options: .prettyPrinted)
                  request.httpBody=jsonData
          }catch{
              print("JSON error: \(error.localizedDescription)")
          }
          session.dataTask(with: request) { data, response, error in
            DispatchQueue.main.async{
                self.removeActivityIndicator()
            }
              if error != nil || data == nil {
                  print(error!.localizedDescription)
                  if error!.localizedDescription=="The Internet connection appears to be offline."{
                      DispatchQueue.main.async{
                      let alertController=UIAlertController(title: "No internet connection", message: "Please recheck connectivity and try again.", preferredStyle: .alert)
                      let okAction=UIAlertAction(title: "Ok", style: .default, handler: nil)
                      alertController.addAction(okAction)
                      self.present(alertController, animated: true, completion: nil)
                  }
                  }
                  return
              }
              guard let data=data else{return}
              if let httpresponse = response as? HTTPURLResponse{
              if (httpresponse.statusCode)==200{
                  print("response:\(httpresponse.statusCode)")
                //print(data)
                do{

                    self.UserInformation=try JSONDecoder().decode([jobsData].self,from:data).sorted{ $0.startDate! > $1.startDate! }
                    let grouped = Dictionary(grouping: self.UserInformation, by: {$0.startDate})
                    self.sections = grouped.map{Section(title: $0.key!, jobsData: $0.value)}
                                          .sorted{$0.title < $1.title}
                    DispatchQueue.main.async {
                        self.collectionView.reloadData()
                    }
                }catch{
                        print("Could not decode data coming from API")
                        let dataString = String(data: data, encoding: .utf8)
                        print((dataString!.description))
                }
                  }
                 else if httpresponse.statusCode==401{
                      print(httpresponse.statusCode)
                self.uptimer!.invalidate()
                      DispatchQueue.main.async {
                          let alertController=UIAlertController(title: "Logged Out", message: "login again to continue using this app", preferredStyle: .alert)
                          let okAction=UIAlertAction(title: "Ok", style: .default,handler:{ _ -> Void in
                              let nav=UINavigationController(rootViewController: LoginViewController())
                              nav.modalPresentationStyle = .fullScreen
                              _ = self.navigationController?.present(nav, animated: true)
                          })
                          alertController.addAction(okAction)
                          self.present(alertController, animated: true, completion: nil)
                      }
                  }
              }
              else{ print("Server error")
                      return
              }
          }.resume()
    }

это timerInvalidate и функция scheduleTimerWithTimeInterval1

    @objc func timerInvalidate1(){
        self.uptimer!.invalidate()
    }

 @objc func scheduledTimerWithTimeInterval1(){
        if self.viewIfLoaded?.window != nil {
        uptimer = Timer.scheduledTimer(timeInterval: 3, target: self, selector:#selector(networkCall1), userInfo: nil, repeats: true)
uptime!.fire()
        }

Я добавил два наблюдателя NotificationCentre для случая, когда приложение переходит в фоновый режим и на передний план для остановки и запуска времени

NotificationCenter.default.addObserver(self, selector: #selector(scheduledTimerWithTimeInterval1), name: UIApplication.willEnterForegroundNotification, object: nil)
        NotificationCenter.default.addObserver(self, selector: #selector(timerInvalidate1), name: UIApplication.didEnterBackgroundNotification, object: nil)

, и я объявил переменную таймера в ViewController. Основной класс, как это:

var uptimer:Timer?

, пожалуйста, дайте мне знать, в чем проблема и как я могу решить эту проблему

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...