From a02e85b2a3ce6f5bfd4fa1523d2fe9c1b0a73ddd Mon Sep 17 00:00:00 2001 From: Viswanathan Munisamy Date: Thu, 3 Oct 2024 11:53:40 -0700 Subject: [PATCH 1/3] Protect NetworkTrace state variables for thread safety. --- .../Sources/Instrumentation/FPRNetworkTrace.m | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/FirebasePerformance/Sources/Instrumentation/FPRNetworkTrace.m b/FirebasePerformance/Sources/Instrumentation/FPRNetworkTrace.m index f08015c8cf4..380e57dae0e 100644 --- a/FirebasePerformance/Sources/Instrumentation/FPRNetworkTrace.m +++ b/FirebasePerformance/Sources/Instrumentation/FPRNetworkTrace.m @@ -233,7 +233,9 @@ - (NSTimeInterval)startTimeSinceEpoch { #pragma mark - Overrides - (void)setResponseCode:(int32_t)responseCode { - _responseCode = responseCode; + dispatch_sync(self.syncQueue, ^{ + _responseCode = responseCode; + }); if (responseCode != 0) { _hasValidResponseCode = YES; } @@ -279,7 +281,9 @@ - (void)didUploadFileWithURL:(NSURL *)URL { } - (void)didReceiveData:(NSData *)data { - self.responseSize = data.length; + dispatch_sync(self.syncQueue, ^{ + self.responseSize = data.length; + }); } - (void)didReceiveFileURL:(NSURL *)URL { @@ -290,7 +294,9 @@ - (void)didReceiveFileURL:(NSURL *)URL { if (error) { FPRLogNotice(kFPRNetworkTraceFileError, @"Unable to determine the size of file."); } else { - self.responseSize = value.unsignedIntegerValue; + dispatch_sync(self.syncQueue, ^{ + self.responseSize = value.unsignedIntegerValue; + }); } } } From 51d658a7c154d5e82fc8fb4877fbed43749a77a5 Mon Sep 17 00:00:00 2001 From: Viswanathan Munisamy Date: Thu, 3 Oct 2024 11:57:16 -0700 Subject: [PATCH 2/3] Update Changelog. --- FirebasePerformance/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/FirebasePerformance/CHANGELOG.md b/FirebasePerformance/CHANGELOG.md index e1f7548eec1..8cb76fef252 100644 --- a/FirebasePerformance/CHANGELOG.md +++ b/FirebasePerformance/CHANGELOG.md @@ -1,3 +1,6 @@ +# Pending +- [fixed] Fix a crash related to thread sanitization on FPRNetworkTrace class (#13581). + # 10.28.0 - Fix Crash from InstrumentUploadTaskWithStreamedRequest (#12983). - Replace SystemConfiguration with a more recent network monitoring API by Apple (#13079). From 35ad538bc5d788c203bcecb85ccbffd4091d6bb2 Mon Sep 17 00:00:00 2001 From: Visu Date: Thu, 3 Oct 2024 12:04:54 -0700 Subject: [PATCH 3/3] Update FirebasePerformance/CHANGELOG.md Co-authored-by: Nick Cooke <36927374+ncooke3@users.noreply.github.com> --- FirebasePerformance/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FirebasePerformance/CHANGELOG.md b/FirebasePerformance/CHANGELOG.md index 8cb76fef252..0863831c286 100644 --- a/FirebasePerformance/CHANGELOG.md +++ b/FirebasePerformance/CHANGELOG.md @@ -1,4 +1,4 @@ -# Pending +# Unreleased - [fixed] Fix a crash related to thread sanitization on FPRNetworkTrace class (#13581). # 10.28.0