title: Crash: libsystem_pthread.dylib: _pthread_wqthread
body: <p>This is the number 1 crash of my application in the AppStore. Problem is I can't find a solution to this thing, because I can't reproduce it and don't know what is causing it. The crashlog says the following:</p>
  
  <p>Thread 0.8 is <code>didUpdateLocations</code>.</p>
  
  <p><a href="https://i.stack.imgur.com/wfFiT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wfFiT.png" alt="First Thread"></a>
  <a href="https://i.stack.imgur.com/j3VtJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j3VtJ.png" alt="Last 2 Thread"></a></p>
  
  <p>I thought it might be in <code>checkStealRange()</code>, but I don't see something wrong with that.</p>
  
  <pre><code>func checkStealRange() {
  
      var objectsWithdistance = [PFObject]()
      stealobject = nil
      print("checkin steal and setting stealobject to nil")
  
      if nearbystreets.count != 0 {
          for object in self.nearbystreets {
              if let lon = object["lon"] as? Double, let lat = object["lat"] as? Double{
                  let locationStreet = CLLocation(latitude: lat, longitude: lon)
                  if let currentLocation = self.locationManager.location {
                      let distance = currentLocation.distance(from: locationStreet)
                      object["distance"] = distance
                      objectsWithdistance.append(object)
                  } else {
                      if self.lastlocationregionset != nil {
                          let distance = self.lastlocationregionset!.distance(from: locationStreet)
                          object["distance"] = distance
                          objectsWithdistance.append(object)
                      }
                  }
              }
          }
      } else {
          print("no nearby streets loaded to check for steal")
          stealButton.isEnabled = false
          return
      }
  
      if objectsWithdistance.count &gt; 0 {
          print("objectsWithdistance count:", objectsWithdistance.count)
          let sortedArray = (objectsWithdistance as NSArray).sortedArray(using: [
              NSSortDescriptor(key: "distance", ascending: true)
              ])
          for object in sortedArray {
              guard let street = object as? PFObject else { continue }
              if let streetDistance = street["distance"] as? Double {
                  var allowedDistance = Game.steal.stealMinDistance +
                      Game.steal.stealDistancePerLevel * Double(Main().level())
                  if Main().getStealBoost() {
                      allowedDistance += 250
                  }
                  //print("distance:", streetDistance, "allowed:", allowedDistance)
  
                  guard let user = street["current_owner"] as? PFUser else { continue }
                  if user != PFUser.current() &amp;&amp; streetDistance &lt;= allowedDistance {
                      print("found steal")
                      self.stealobject = street
                      break
                  }
              }
          }
      } else {
          print("checkin steal failed")
          stealButton.isEnabled = false
          return
      }
      print("nearbystreet count:", nearbystreets.count)
  
      if !self.timecheat &amp;&amp; stealobject != nil {
          stealButton.isEnabled = true
      } else {
          stealButton.isEnabled = false
      }
  }
  </code></pre>