pinterest / PINCache

Fast, non-deadlocking parallel object cache for iOS, tvOS and OS X
Apache License 2.0
2.66k stars 361 forks source link

+[PINDiskCache moveItemAtURLToTrash:] (PINDiskCache.m:451) Crashed at -[NSURL fileSystemRepresentation] #303

Open Jason-Stan-Lee opened 3 years ago

Jason-Stan-Lee commented 3 years ago

The _sharedTrashURL generated with [[NSProcessInfo processInfo] globallyUniqueString]; contains %00%00%00%00 , lead to a crash.

Device: iPhone Xr iOS 14.2 (18B92)

*** -[NSURL fileSystemRepresentation]: conversion failed for file:///private/var/mobile/Containers/Data/Application/40AC63D8-3BD7-458B-BAC6-6396A78BD715/tmp/FE7F1C30-38EE-47ED-BB37-8FE73EA7873A-64416-000010D9F50E%00%00%00%00/7F3D3218-6F96-4724-9853-19D242240A2F-64416-000010D9F50F2CDB

0 CoreFoundation | ___exceptionPreprocess + 220
-- | --
1 libobjc.A.dylib | objc_exception_throw + 60
2 Foundation | -[NSURL(NSURL) fileSystemRepresentation] + 668
3 Foundation | -[NSFilesystemItemMoveOperation main] + 124
4 Foundation | ___NSOPERATION_IS_INVOKING_MAIN__ + 24
5 Foundation | -[NSOperation start] + 808
6 Foundation | -[NSFileManager moveItemAtURL:toURL:options:error:] + 312
7 MyApp | +[PINDiskCache moveItemAtURLToTrash:] (PINDiskCache.m:451)
8 MyApp | -[PINDiskCache removeFileAndExecuteBlocksForKey:] (PINDiskCache.m:688)
9 MyApp | -[PINDiskCache trimDiskToSizeByDate:] (PINDiskCache.m:779)
10 MyApp | __49-[PINDiskCache trimToSizeByDateAsync:completion:]_block_invoke (PINDiskCache.m:974)
11 MyApp | __44-[PINOperationQueue scheduleNextOperations:]_block_invoke (PINOperationQueue.m:346)
12 libdispatch.dylib | __dispatch_call_block_and_release + 32
13 libdispatch.dylib | __dispatch_client_callout + 20
14 libdispatch.dylib | __dispatch_lane_serial_drain + 580
garrettmoon commented 3 years ago

@Jason-Stan-Lee Can you post an example project that reproduces this?

Jason-Stan-Lee commented 3 years ago

@Jason-Stan-Lee Can you post an example project that reproduces this?

Nope. It was finded in my crash collector, but I never reproduce this case.

garrettmoon commented 3 years ago

@Jason-Stan-Lee is it something you're seeing occur a lot? Is there any particular version of iOS it occurs on?

Jason-Stan-Lee commented 3 years ago

@Jason-Stan-Lee is it something you're seeing occur a lot? Is there any particular version of iOS it occurs on?

@garrettmoon There are very few crashes, perhaps one over a million or a billion, the platforms which crashed are in following

iPhone Xr | 12.3 (16F156) iPhone 11 Pro Max | 13.3.1 (17D50) iPhone Xr | 13.1.3 (17A878)

I guess the globallyUniqueString is not very suitable for url path.

garrettmoon commented 3 years ago

Got it, thanks for the info!