Skip to content

Conversation

@paulb777
Copy link
Member

Fix firebase/firebase-ios-sdk#15414

Gemini's analysis:

This new stack trace points to a crash within GDTCORDirectorySizeTracker, specifically in the calculateDirectoryContentSize method. This is being called from GDTCORFlatFileStorage when a new event is stored. The crash seems to be related to memory allocation during directory enumeration, which could be caused by a number of factors, including a corrupted file system or an issue with how the directory enumeration is being performed.

After reviewing GDTCORDirectorySizeTracker.m, I see that the crash occurs in the calculateDirectoryContentSize method, which uses an NSDirectoryEnumerator to calculate the total size of all files in a given directory. The stack trace points to a crash deep within CoreFoundation's string creation and memory allocation functions, which suggests that the issue is likely caused by an underlying file system corruption or an unexpected file name that is causing the enumerator to fail.

The current implementation of the enumerator's errorHandler always returns YES, which tells the enumerator to continue even when an error has occurred. This can lead to unpredictable behavior and crashes if the underlying error is serious.

To fix this, I will modify the errorHandler to return NO when an error is encountered. This will stop the enumerator and prevent it from attempting to process any more files, which should prevent the crash. This change will make the directory size calculation more robust and prevent crashes caused by file system errors.

@google-oss-bot
Copy link

Coverage Report 1

Affected Products

  • GoogleDataTransport-ios-GoogleDataTransport.framework

    Overall coverage changed from 76.33% (5a9a019) to 63.05% (59c433b) by -13.29%.

    FilenameBase (5a9a019)Merge (59c433b)Diff
    GDTCCTCompressionHelper.m81.63%0.00%-81.63%
    GDTCCTNanopbHelpers.m56.30%0.00%-56.30%
    GDTCCTUploader.m62.00%54.00%-8.00%
    GDTCCTUploadOperation.m74.54%28.41%-46.13%
    GDTCCTURLSessionDataResponse.m100.00%0.00%-100.00%
    GDTCOREvent+GDTCCTSupport.m16.49%0.00%-16.49%
    GDTCORFlatFileStorage+Promises.m74.14%46.55%-27.59%
    GDTCORPlatform.m82.26%72.26%-10.00%
    GDTCORUploadBatch.m100.00%0.00%-100.00%

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/Y9KUqI3lig.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

-[GDTCORDirectorySizeTracker calculateDirectoryContentSize] app crash

2 participants