Skip to content

Commit

Permalink
Added lock around RN module initialization to fix crash
Browse files Browse the repository at this point in the history
Summary:
T35879909 is a UBN caused by a race condition in RN initialization. I haven't been able to repro, but the crash logs point to a bad memory access in this method. Another thread must be deallocating something concurrently.

This is a quick fix to patch into v197.

Reviewed By: fkgozali

Differential Revision: D12904277

fbshipit-source-id: 5740183f9a7c8f2c45ca627662891cb0c1048764
  • Loading branch information
Peter Argany authored and facebook-github-bot committed Nov 2, 2018
1 parent 28de61e commit 6770b53
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions React/CxxBridge/RCTCxxBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -706,9 +706,11 @@ - (void)registerExtraLazyModules

- (void)registerAdditionalModuleClasses:(NSArray<Class> *)modules
{
NSArray<RCTModuleData *> *newModules = [self _initializeModules:modules withDispatchGroup:NULL lazilyDiscovered:YES];
if (_reactInstance) {
_reactInstance->getModuleRegistry().registerModules(createNativeModules(newModules, self, _reactInstance));
@synchronized (self) {
NSArray<RCTModuleData *> *newModules = [self _initializeModules:modules withDispatchGroup:NULL lazilyDiscovered:YES];
if (_reactInstance) {
_reactInstance->getModuleRegistry().registerModules(createNativeModules(newModules, self, _reactInstance));
}
}
}

Expand Down

0 comments on commit 6770b53

Please sign in to comment.