Permalink
Browse files

Added lock around RN module initialization to fix crash

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...
PeteTheHeat authored and facebook-github-bot committed Nov 2, 2018
1 parent 28de61e commit 6770b53f8d064a6d14cbd8dd8dcfdc27ac98deb0
Showing with 5 additions and 3 deletions.
  1. +5 −3 React/CxxBridge/RCTCxxBridge.mm
@@ -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));
}
}
}

0 comments on commit 6770b53

Please sign in to comment.