andysmart / Timberjack

Automatic network activity logger for iOS and OSX
MIT License
158 stars 43 forks source link

SIGSEGV segmentation fault when accessing default Timberjack session configuration #27

Open briandavidelliott opened 7 years ago

briandavidelliott commented 7 years ago

I am seeing a crash (SIGSEGV - invalid memory address) in the following code when calling the Alamofire HTTPManager and passing the results of a call to the Timberjack.defaultSessionConfiguration():

class HTTPManager: Alamofire.SessionManager {

static let shared: HTTPManager = {
    let configuration = Timberjack.defaultSessionConfiguration()
    let manager = HTTPManager(configuration: configuration) . <=== Crashes here
    return manager
}()

}

The is following the example in the Timberjack README file (https://github.com/andysmart/Timberjack)

And our network calls look like this:

class DataAgent: NSObject, NSCoding {

public static var manager:NetworkManager = NetworkManager()

let request:DataRequest = manager.networkRequest("(DataAgent.api_url)", method:NetworkingConstants.HTTPMethod.post, params: params) request.validate() .responseJSON { response in switch response.result { case .success(let data): DataAgent.tokenCallback(json: JSON(data)) DataAgent.scope = role print("Login Successful! (DataAgent.access_token ?? "UNDEFINED")") completion(true)

                    case .failure(let error):
                        print("Login Failed: \(error)")
                        completion(false)
                }
            }

And the network request is in my NetworkManager class:

func networkRequest<T> (_ url:String, method:NetworkingConstants.HTTPMethod, params:[String : Any], mock:Bool = false) -> T  {
       ...
        let parameters:Parameters = params
        let returnRequest:DataRequest = HTTPManager.shared.request(url, method: getAlamofireMethod(method), parameters: parameters)
        return returnRequest as! T
      ...
}

But I am not able to reproduce this one on-demand but am seeing that my users are experiencing it.