-->

Crash being reported for ALAssetRepresentation met

2020-06-02 08:13发布

问题:

I have some code that wraps an ALAsset object that is retrieved from enumerating the assets in an ALAssetLibrary. I'm getting reports of users encountering crashes with the part of the wrapper object that asks the ALAsset it contains for metadata.

The code that crashes is in this wrapper class and it simply asks for its ALAsset's metadata like so:

[[myAlAsset defaultRepresentation] metadata]; 

Here is a partial stack trace that is representative of the crashes I'm seeing:

0
CoreFoundation   CFDataGetBytePtr + 5
1
PhotoLibraryServices     __46-[PLManagedAsset adjustmentsXMPRepresentation]_block_invoke + 228
2
PhotoLibraryServices     __46-[PLManagedAsset adjustmentsXMPRepresentation]_block_invoke + 228
3
CoreData     developerSubmittedBlockToNSManagedObjectContextPerform + 88
4
CoreData     -[NSManagedObjectContext performBlockAndWait:] + 114
5
PhotoLibraryServices     -[PLManagedAsset adjustmentsXMPRepresentation] + 226
6
AssetsLibrary    __33-[ALAssetRepresentation metadata]_block_invoke + 24
7
AssetsLibrary    __53-[ALAssetRepresentationPrivate _performBlockAndWait:]_block_invoke + 68
8
CoreData     developerSubmittedBlockToNSManagedObjectContextPerform + 88
9
libdispatch.dylib    _dispatch_client_callout + 22
10
libdispatch.dylib    _dispatch_barrier_sync_f_invoke + 26
11
CoreData     -[NSManagedObjectContext performBlockAndWait:] + 106
12
AssetsLibrary    -[ALAssetsLibrary _performBlockAndWait:] + 134
13
AssetsLibrary    -[ALAssetRepresentationPrivate _performBlockAndWait:] + 176
14
AssetsLibrary    -[ALAssetRepresentation metadata] + 464

Does anyone have ideas on what may be going on? The AlAssetLibrary that underlies these assets is saved with a static reference, so it should not be getting cleaned up in memory and so I wouldn't expect the ALAsset to have been invalidated. This issue seems to have started specifically with iOS 7 being released.

The crash itself is EXC_BAD_ACCESS with KERN_INVALID_ADDRESS at 0x0.

回答1:

This may have caused because of buffer overflows. Pls check the link of apple website which shows the buffer overflow crash report same as you have. Hope this may help you.

https://developer.apple.com/library/ios/documentation/Security/Conceptual/SecureCodingGuide/Articles/BufferOverflows.html#//apple_ref/doc/uid/TP40002577-SW1