2016-04-13 69 views
2

我突然开始观察下一次崩溃,对我的某个应用程序进行了新更新。它似乎很频繁地发生,并且令人困惑,因为我在过去6个月中没有对代码的这一部分进行更改。我想知道this(EXC_BAD_ACCESS在返回投掷字典时)如果崩溃是由于为这个请求形成params字典导致的,那么Swift雷达的bug可能是相关的。swift_unknown发布崩溃 - SwiftHTTP

更新 此版本使用Swift 2.2和Xcode 7.3创建。 SwiftHTTP是v1.0.4。我在iOS 8.3.0,9.3.0和9.3.1上看到生产二进制文件崩溃。这个问题在iPhone 6,6 Plus和6s上最普遍(87%)。我曾尝试使用Xcode Zombies重新生成此问题(根据here),但它没有在控制台中显示任何message sent to deallocated instance消息。

崩溃发生在我为SwiftHTTP库的帮助类中执行PUT更新。

错误

EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000020 

堆栈跟踪

Thread : Crashed: com.apple.main-thread 
0 libswiftCore.dylib    0x100d6d8f8 swift_unknownRelease + 24 
1 SwiftHTTP      0x100b07298 _TTSf4g_n___TTSg5Ps9AnyObject____TFE9SwiftHTTPSa11createPairsfGSqSS_GSaVS_8HTTPPair_ + 700 
2 SwiftHTTP      0x100b002f4 _TFE9SwiftHTTPVs10Dictionary11createPairsfGSqSS_GSaVS_8HTTPPair_ + 2000 
3 SwiftHTTP      0x100b00f90 _TTWu0_Rxs8HashablerGVs10Dictionaryxq__9SwiftHTTP21HTTPParameterProtocolS1_FS2_11createPairsfGSqSS_GSaVS1_8HTTPPair_ + 112 
4 SwiftHTTP      0x100b0178c _TFE9SwiftHTTPCSo19NSMutableURLRequest16appendParametersfzPS_21HTTPParameterProtocol_T_ + 396 
5 SwiftHTTP      0x100af14a4 _TTWV9SwiftHTTP23HTTPParameterSerializerS_21HTTPSerializeProtocolS_FS1_9serializefzTCSo19NSMutableURLRequest10parametersPS_21HTTPParameterProtocol__T_ + 40 
6 SwiftHTTP      0x100af8ccc _TTSf4gs_n_n_g_n_d___TZFC9SwiftHTTP4HTTP3NewfzTSS6methodOS_8HTTPVerb10parametersGSqPS_21HTTPParameterProtocol__7headersGSqGVs10DictionarySSSS__17requestSerializerPS_21HTTPSerializeProtocol__S0_ + 624 
7 SwiftHTTP      0x100af5758 _TZFC9SwiftHTTP4HTTP3PUTfzTSS10parametersGSqPS_21HTTPParameterProtocol__7headersGSqGVs10DictionarySSSS__17requestSerializerPS_21HTTPSerializeProtocol__S0_ + 76 
8 MyApp     0x1001274c0 SwiftHTTPUtilities.PUT(String, auth : String, params : [String : AnyObject]?, model : String, mode : APIUtilities.ApiRequestType, object : AnyObject?) ->() (SwiftHTTPUtilities.swift:52) 
9 MyApp     0x100154e90 APIUtilities.(apiRequest(String, mode : APIUtilities.ApiRequestType, object : AnyObject?) ->()).(closure #3) (APIUtilities.swift:76) 
10 MyApp     0x100152f70 partial apply for APIUtilities.(apiRequest(String, mode : APIUtilities.ApiRequestType, object : AnyObject?) ->()).(closure #3) (APIUtilities.swift) 
11 libdispatch.dylib    0x18364d4bc _dispatch_call_block_and_release + 24 
12 libdispatch.dylib    0x18364d47c _dispatch_client_callout + 16 
13 libdispatch.dylib    0x183652b84 _dispatch_main_queue_callback_4CF + 1844 
14 CoreFoundation     0x183bb8dd8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 
15 CoreFoundation     0x183bb6c40 __CFRunLoopRun + 1628 
16 CoreFoundation     0x183ae0d10 CFRunLoopRunSpecific + 384 
17 GraphicsServices    0x1853c8088 GSEventRunModal + 180 
18 UIKit       0x188db5f70 UIApplicationMain + 204 
19 MyApp     0x10026d508 main (AppDelegate.swift:25) 
20 libdispatch.dylib    0x18367e8b8 (Missing) 

SwiftHTTPUtilities(它是一个辅助类与开源库SwiftHTTP交互)

func PUT(apiPath: String, auth: String, params: Dictionary<String,AnyObject>?,model: String, mode: APIUtilities.ApiRequestType, object: AnyObject?) {   
      do { 
//SYMBOLICATED CRASH REPORT IDENTIFIES BELOW LINE FOR EXC_BAD_ACCESS 
       let opt = try HTTP.PUT("\(apiPath)", parameters: params, headers: ["*removed*"]) 
       opt.start { response in 
        if let err = response.error { 
//      print("error: \(err.localizedDescription)") 
         self.delegate?.didGetServerResponse(false, response: nil, error: response.error, model: model, mode: mode, object: object) 
         return //also notify app of failure as needed 
        } 
//     print("opt finished: \(response.description)") 
        //print("data is: \(response.data)") access the response of the data with response.data 

        self.delegate?.didGetServerResponse(true, response: response.data, error: nil, model: model, mode: mode, object: object) 
       } 
      } catch let error { 
//    print("got an error creating the request: \(error)") 
       self.delegate?.didGetServerResponse(false, response: nil, error: nil, model: model, mode: mode, object: object) 
      } 

    } 
+0

您是否尝试清洁和构建?有时候撞车实际上并不是一蹴而就的。 – Varun

+0

在App Store上的生产二进制文件中正在观察此崩溃。我还没有能够在我的物理设备上复制这个崩溃(即触发这个功能不会让我崩溃),但已经看到有关Crashlytics的报告。 – upperlacon

+0

好的。它是建立在Swift 1.0还是2.0?和Xcode版本? – Varun

回答

0

此问题是由于SwiftHTTP默认为HTTPSerialisation。下面的一行是如何指定JSON序列化,它为我解决了这个错误。

let opt = try HTTP.New("\(apiPath)", method: .PUT, parameters: params, headers: ["Authorization": "edit"], requestSerializer: JSONParameterSerializer())