Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RNFSManager iOS 14.5.1 crash #1012

Open
acidumirae opened this issue May 24, 2021 · 1 comment
Open

RNFSManager iOS 14.5.1 crash #1012

acidumirae opened this issue May 24, 2021 · 1 comment

Comments

@acidumirae
Copy link

acidumirae commented May 24, 2021

I am getting the following crash on iOS 14.5.1

Exception '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[4]' was thrown while invoking readDir on target RNFSManager with params (
    "/var/mobile/Containers/Data/Application/98538D77-2F00-4B2B-A327-C08D6DC4058C",
    26,
    27
)
callstack: (
	0   CoreFoundation                      0x000000018465e5c8 58500388-BF36-397C-84CF-17315A3445B6 + 1217992
	1   libobjc.A.dylib                     0x00000001990dd7a8 objc_exception_throw + 60
	2   CoreFoundation                      0x00000001846d0a80 58500388-BF36-397C-84CF-17315A3445B6 + 1686144
	3   CoreFoundation                      0x00000001846dcad8 58500388-BF36-397C-84CF-17315A3445B6 + 1735384
	4   CoreFoundation                      0x000000018454b360 58500388-BF36-397C-84CF-17315A3445B6 + 90976
	5   CoreFoundation                      0x000000018453dc80 58500388-BF36-397C-84CF-17315A3445B6 + 35968
	6   WorkerEval                          0x0000000100c18c74 __41-[RNFSManager readDir:resolver:rejecter:]_block_invoke + 636
	7   WorkerEval                          0x0000000100c186c0 __42-[NSArray(Map) rnfs_mapObjectsUsingBlock:]_block_invoke + 112
	8   CoreFoundation                      0x00000001845dc41c 58500388-BF36-397C-84CF-17315A3445B6 + 685084
	9   CoreFoundation                      0x0000000184536d44 58500388-BF36-397C-84CF-17315A3445B6 + 7492
	10  WorkerEval                          0x0000000100c18600 -[NSArray(Map) rnfs_mapObjectsUsingBlock:] + 272
	11  WorkerEval                          0x0000000100c1891c -[RNFSManager readDir:resolver:rejecter:] + 360
	12  CoreFoundation                      0x0000000184663874 58500388-BF36-397C-84CF-17315A3445B6 + 1239156
	13  CoreFoundation                      0x0000000184536ba4 58500388-BF36-397C-84CF-17315A3445B6 + 7076
	14  CoreFoundation                      0x00000001845371a8 58500388-BF36-397C-84CF-17315A3445B6 + 8616
	15  WorkerEval                          0x0000000100d2ab14 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 1752
	16  WorkerEval                          0x0000000100d2de58 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 604
	17  WorkerEval                          0x0000000100d2da38 _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 128
	18  WorkerEval                          0x0000000100d2d9ac ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 28
	19  libdispatch.dylib                   0x000000010403c064 _dispatch_call_block_and_release + 32
	20  libdispatch.dylib                   0x000000010403dd90 _dispatch_client_callout + 20
	21  libdispatch.dylib                   0x0000000104045ea0 _dispatch_lane_serial_drain + 788
	22  libdispatch.dylib                   0x0000000104046cc4 _dispatch_lane_invoke + 444
	23  libdispatch.dylib                   0x0000000104053a00 _dispatch_workloop_worker_thread + 1600
	24  libsystem_pthread.dylib             0x00000001d01967a4 _pthread_wqthread + 276
	25  libsystem_pthread.dylib             0x00000001d019d74c start_wqthread + 8
)
RCTFatal
facebook::react::invokeInner(RCTBridge*, RCTModuleData*, unsigned int, folly::dynamic const&)
facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)::$_0::operator()() const
invocation function for block in facebook::react::RCTNativeModule::invoke(unsigned int, folly::dynamic&&, int)
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_lane_serial_drain
_dispatch_lane_invoke
_dispatch_workloop_worker_thread
_pthread_wqthread
start_wqthread

This appears to be here:

https://github.com/itinance/react-native-fs/blob/master/RNFSManager.m#L63

It is crashing on trying to read a hidden file which the app does not have access to, even it is in apps directory:

.com.apple.mobile_container_manager.metadata.plist

A patch like this to skip the hidden files makes the crash go away:

59,69c59
<   NSMutableArray *tagetContents = [[NSMutableArray alloc] init];
<   NSArray *sourceContents = [fileManager contentsOfDirectoryAtPath:dirPath error:&error];
<   for (NSString *object in sourceContents) {
<     unichar firstChar = [object characterAtIndex:0];
<     if(firstChar == '.') {
<         NSLog(@"Skipping the hidden file: %@", object);
<     } else {
<         [tagetContents addObject:object];
<     }
<   }
<   NSArray *contents = [tagetContents copy];
---
>   NSArray *contents = [fileManager contentsOfDirectoryAtPath:dirPath error:&error];
@desmondmc
Copy link

@itinance I think you can close this issue. Looks like it's been fixed.

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

No branches or pull requests

2 participants