Files
react-native/packages
Saad NajmiandFacebook GitHub Bot 6bc5ddea3e fix: avoid race condition crash in [RCTDataRequestHandler invalidate] (#49705)
Summary:
Upstreaming a fix by ntre that fixes a crash we saw internally related to `[_queue cancelAllOperations]`.

>Calling [_queue cancelAllOperations] will release all references to any active operations.
>If the blocks of those operations have a reference to itself, it will result in dangling pointers, which could conceptually trigger a later crash if there's a race between the operation completing and it being pulled out of the queue.
>
>Add explicit strong reference while block is running.
>For good measure, fix same pattern also in RCTFileRequestHandler.
>
>Note: separately, that this code is passing the op itself as a requestToken to [delegate URLRequest:] methods is suspect. That delegate can retain said token.

## Changelog:

[IOS] [FIXED] - avoid race condition crash in [RCTDataRequestHandler invalidate]

Pull Request resolved: https://github.com/facebook/react-native/pull/49705

Test Plan: Tested internally, we no longer saw the crash after this fix.

Reviewed By: javache

Differential Revision: D70314889

Pulled By: cipolleschi

fbshipit-source-id: ebcecb4675bd1dda3d9ee60d69967feb4e05e11b
2025-03-03 05:58:07 -08:00
..
2025-02-27 09:05:55 -08:00
2025-02-27 03:13:26 -08:00