From 0ba47d9a71f15f513f5de39852f6582666f23ce2 Mon Sep 17 00:00:00 2001 From: LAgagggggg <15807814960@163.com> Date: Fri, 4 Oct 2019 05:36:41 -0700 Subject: [PATCH] Fix crash of iOS FlipperNetworkPlugin (#563) Summary: Flipper's network plugin may cause crash on a frequency of about one time per 1~2 days(I think it depends on how many network request we send). ![IMG_3095](https://user-images.githubusercontent.com/24563710/65739973-cc540080-e119-11e9-9e6e-e4a925ecc63c.JPG) I assume the crash is caused by part of the code of HTTPParser is not thread-safe, and invoke it asynchronously may cause double-free crash. So I manually ask for HTTPBody synchronously, make the HTTPParser parse the request and cache them in advance, before any possible asynchronous invoking. ## Changelog Fix potential crash cause by network plugin. Pull Request resolved: https://github.com/facebook/flipper/pull/563 Test Plan: 1. Run our App with Flipper integrated 2. Make sure FlipperNetworkPlugin is active 3. It may take days to reproduce the crash Reviewed By: passy Differential Revision: D17739327 Pulled By: priteshrnandgaonkar fbshipit-source-id: e814145c346bd2da1d2f5f87b6a2f7e200f0bf2d --- .../FLEXNetworkLib/FLEXNetworkObserver.mm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/iOS/Plugins/FlipperKitNetworkPlugin/SKIOSNetworkPlugin/FLEXNetworkLib/FLEXNetworkObserver.mm b/iOS/Plugins/FlipperKitNetworkPlugin/SKIOSNetworkPlugin/FLEXNetworkLib/FLEXNetworkObserver.mm index 5bb582c20..75f2e86c3 100755 --- a/iOS/Plugins/FlipperKitNetworkPlugin/SKIOSNetworkPlugin/FLEXNetworkLib/FLEXNetworkObserver.mm +++ b/iOS/Plugins/FlipperKitNetworkPlugin/SKIOSNetworkPlugin/FLEXNetworkLib/FLEXNetworkObserver.mm @@ -274,6 +274,14 @@ didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask delegate:(id