qiniu/objc-sdk

NSAllocateMemoryPages(2097152) failed

tangbl93 opened this issue · 4 comments

这个崩溃怎么导致的看不太懂,麻烦七牛的大佬看看有没有办法解决

SDK版本号:Qiniu (~> 8.3.2)

崩溃信息
崩溃堆栈

崩溃汇编信息

Foundation`-[_NSPlaceholderData initWithBytes:length:copy:deallocator:]:
    0x193639a90 <+0>:   stp    x24, x23, [sp, #-0x40]!
    0x193639a94 <+4>:   stp    x22, x21, [sp, #0x10]
    0x193639a98 <+8>:   stp    x20, x19, [sp, #0x20]
    0x193639a9c <+12>:  stp    x29, x30, [sp, #0x30]
    0x193639aa0 <+16>:  add    x29, sp, #0x30            ; =0x30 
    0x193639aa4 <+20>:  mov    x19, x5
    0x193639aa8 <+24>:  mov    x20, x3
    0x193639aac <+28>:  mov    x21, x2
    0x193639ab0 <+32>:  cbz    x3, 0x193639af4           ; <+100>
    0x193639ab4 <+36>:  mov    x22, x4
    0x193639ab8 <+40>:  mov    w8, #0xfff6
    0x193639abc <+44>:  cmp    x20, x8
    0x193639ac0 <+48>:  b.hi   0x193639b18               ; <+136>
    0x193639ac4 <+52>:  cbz    w22, 0x193639b18          ; <+136>
    0x193639ac8 <+56>:  adrp   x8, 329575
    0x193639acc <+60>:  ldr    x0, [x8, #0x528]
    0x193639ad0 <+64>:  mov    x1, x20
    0x193639ad4 <+68>:  mov    x2, #0x0
    0x193639ad8 <+72>:  bl     0x19374bc50               ; NSAllocateObject
    0x193639adc <+76>:  adrp   x8, 302929
    0x193639ae0 <+80>:  add    x1, x8, #0x241            ; =0x241 
    0x193639ae4 <+84>:  mov    x2, x21
    0x193639ae8 <+88>:  mov    x3, x20
    0x193639aec <+92>:  bl     0x1920a3e68
    0x193639af0 <+96>:  b      0x193639b08               ; <+120>
    0x193639af4 <+100>: adrp   x8, 332123
    0x193639af8 <+104>: ldr    x0, [x8, #0xb70]
    0x193639afc <+108>: adrp   x8, 303288
    0x193639b00 <+112>: add    x1, x8, #0x341            ; =0x341 
    0x193639b04 <+116>: bl     0x1920a3e68
    0x193639b08 <+120>: mov    x23, x0
    0x193639b0c <+124>: mov    w8, #0x0
    0x193639b10 <+128>: cbnz   x19, 0x193639c3c          ; <+428>
    0x193639b14 <+132>: b      0x193639c54               ; <+452>
    0x193639b18 <+136>: tbz    w22, #0x0, 0x193639bb4    ; <+292>
    0x193639b1c <+140>: mov    x0, x20
    0x193639b20 <+144>: bl     0x1937567f0               ; NSAllocateMemoryPages
->  0x193639b24 <+148>: mov    x23, x0
    0x193639b28 <+152>: mov    x2, x20
    0x193639b2c <+156>: mov    x1, x21
    0x193639b30 <+160>: cmp    x20, #0x80, lsl #12       ; =0x80000 
    0x193639b34 <+164>: b.lo   0x193639bac               ; <+284>
    0x193639b38 <+168>: orr    x8, x23, x21
    0x193639b3c <+172>: adrp   x24, 332019
    0x193639b40 <+176>: ldr    x24, [x24, #0x1f8]
    0x193639b44 <+180>: ldr    x9, [x24]
    0x193639b48 <+184>: sub    x9, x9, #0x1              ; =0x1 
    0x193639b4c <+188>: mov    x0, x23
    0x193639b50 <+192>: mov    x2, x20
    0x193639b54 <+196>: mov    x1, x21
    0x193639b58 <+200>: tst    x9, x8
    0x193639b5c <+204>: b.ne   0x193639bac               ; <+284>
    0x193639b60 <+208>: bl     0x1938572d0               ; symbol stub for: -[_NSPersonNameComponentsStyleFormatter fallbackStyleFormatter]
    0x193639b64 <+212>: mov    x1, x21
    0x193639b68 <+216>: bl     0x193857318               ; symbol stub for: -[_NSPersonNameComponentsStyleFormatterAvatar shouldFallBack]
    0x193639b6c <+220>: mov    x8, x0
    0x193639b70 <+224>: mov    x0, x23
    0x193639b74 <+228>: mov    x2, x20
    0x193639b78 <+232>: mov    x1, x21
    0x193639b7c <+236>: cbnz   w8, 0x193639bac           ; <+284>
    0x193639b80 <+240>: ldr    x8, [x24]
    0x193639b84 <+244>: neg    x8, x8
    0x193639b88 <+248>: and    x24, x8, x20
    0x193639b8c <+252>: mov    x0, x21
    0x193639b90 <+256>: mov    x1, x23
    0x193639b94 <+260>: mov    x2, x24
    0x193639b98 <+264>: bl     0x193758124               ; NSCopyMemoryPages
    0x193639b9c <+268>: subs   x2, x20, x24
    0x193639ba0 <+272>: b.eq   0x193639c14               ; <+388>
    0x193639ba4 <+276>: add    x1, x21, x24
    0x193639ba8 <+280>: add    x0, x23, x24
    0x193639bac <+284>: bl     0x193857378               ; symbol stub for: -[_NSPersonNameComponentsStyleFormatterFamilyInitialVariant abbreviatedKeys]
    0x193639bb0 <+288>: b      0x193639c14               ; <+388>
    0x193639bb4 <+292>: adrp   x8, 332022
    0x193639bb8 <+296>: add    x8, x8, #0x340            ; =0x340 
    0x193639bbc <+300>: mov    x23, x21
    0x193639bc0 <+304>: cmp    x19, x8
    0x193639bc4 <+308>: b.eq   0x193639c14               ; <+388>
    0x193639bc8 <+312>: adrp   x8, 332022
    0x193639bcc <+316>: add    x8, x8, #0x368            ; =0x368 
    0x193639bd0 <+320>: mov    x23, x21
    0x193639bd4 <+324>: cmp    x19, x8
    0x193639bd8 <+328>: b.eq   0x193639c14               ; <+388>
    0x193639bdc <+332>: adrp   x8, 332123
    0x193639be0 <+336>: ldr    x0, [x8, #0xb78]
    0x193639be4 <+340>: bl     0x1924d7bdc               ; symbol stub for: -[NSMutableArray replaceObjectsInRange:withObjectsFromArray:].cold.1
    0x193639be8 <+344>: adrp   x8, 301583
    0x193639bec <+348>: add    x1, x8, #0xc00            ; =0xc00 
    0x193639bf0 <+352>: mov    x2, x21
    0x193639bf4 <+356>: mov    x3, x20
    0x193639bf8 <+360>: mov    w4, #0x0
    0x193639bfc <+364>: mov    x5, x19
    0x193639c00 <+368>: ldp    x29, x30, [sp, #0x30]
    0x193639c04 <+372>: ldp    x20, x19, [sp, #0x20]
    0x193639c08 <+376>: ldp    x22, x21, [sp, #0x10]
    0x193639c0c <+380>: ldp    x24, x23, [sp], #0x40
    0x193639c10 <+384>: b      0x1920a3e68
    0x193639c14 <+388>: adrp   x8, 332018
    0x193639c18 <+392>: ldr    x8, [x8, #0xcf0]
    0x193639c1c <+396>: ldr    x3, [x8]
    0x193639c20 <+400>: mov    x0, x23
    0x193639c24 <+404>: mov    x1, x20
    0x193639c28 <+408>: mov    x2, #0x0
    0x193639c2c <+412>: bl     0x193856d0c               ; symbol stub for: -[NSUbiquitousKeyValueStore _setShouldAvoidSynchronize:]
    0x193639c30 <+416>: mov    x23, x0
    0x193639c34 <+420>: eor    w8, w22, #0x1
    0x193639c38 <+424>: cbz    x19, 0x193639c54          ; <+452>
    0x193639c3c <+428>: tbnz   w8, #0x0, 0x193639c54     ; <+452>
    0x193639c40 <+432>: ldr    x8, [x19, #0x10]
    0x193639c44 <+436>: mov    x0, x19
    0x193639c48 <+440>: mov    x1, x21
    0x193639c4c <+444>: mov    x2, x20
    0x193639c50 <+448>: blr    x8
    0x193639c54 <+452>: mov    x0, x23
    0x193639c58 <+456>: ldp    x29, x30, [sp, #0x30]
    0x193639c5c <+460>: ldp    x20, x19, [sp, #0x20]
    0x193639c60 <+464>: ldp    x22, x21, [sp, #0x10]
    0x193639c64 <+468>: ldp    x24, x23, [sp], #0x40
    0x193639c68 <+472>: ret    

lldb bt

* thread #65, name = 'com.apple.CFNetwork.CustomProtocols', stop reason = hit Objective-C exception
    frame #0: 0x00000001a61b9448 libobjc.A.dylib`objc_exception_throw
    frame #1: 0x00000001937568b4 Foundation`NSAllocateMemoryPages + 196
  * frame #2: 0x0000000193639b24 Foundation`-[_NSPlaceholderData initWithBytes:length:copy:deallocator:] + 148
    frame #3: 0x00000001134ae70c Qiniu`-[NSURLRequest(self=<unavailable>, _cmd=<unavailable>) qn_getHttpBody] at NSURLRequest+QNRequest.m:88:12 [opt]
    frame #4: 0x00000001134b37b4 Qiniu`-[QNCFHttpClient setupProgress](self=0x0000000282a717c0, _cmd=<unavailable>) at QNCFHttpClient.m:310:51 [opt]
    frame #5: 0x00000001134b27c8 Qiniu`-[QNCFHttpClient setup:](self=0x0000000282a717c0, _cmd=<unavailable>, request=<unavailable>) at QNCFHttpClient.m:52:9 [opt]
    frame #6: 0x00000001134b266c Qiniu`+[QNCFHttpClient client:](self=<unavailable>, _cmd=<unavailable>, request=<unavailable>) at QNCFHttpClient.m:37:5 [opt]
    frame #7: 0x00000001134e8d90 Qiniu`-[QNURLProtocol loadingRequest:](self=0x0000000280c2bd00, _cmd=<unavailable>, request=<unavailable>) at QNURLProtocol.m:178:24 [opt]
    frame #8: 0x00000001134e8cfc Qiniu`-[QNURLProtocol startLoading](self=0x0000000280c2bd00, _cmd=<unavailable>) at QNURLProtocol.m:166:5 [opt]
    frame #9: 0x0000000192a5be8c CFNetwork`___lldb_unnamed_symbol590$$CFNetwork + 236
    frame #10: 0x0000000113cc932c libdispatch.dylib`_dispatch_client_callout + 16
    frame #11: 0x0000000113ccc7e4 libdispatch.dylib`_dispatch_block_invoke_direct + 232
    frame #12: 0x0000000192c706d0 CFNetwork`___lldb_unnamed_symbol11158$$CFNetwork + 36
    frame #13: 0x00000001923763a0 CoreFoundation`CFArrayApplyFunction + 80
    frame #14: 0x0000000192c705f8 CFNetwork`___lldb_unnamed_symbol11157$$CFNetwork + 124
    frame #15: 0x0000000192c72418 CFNetwork`___lldb_unnamed_symbol11226$$CFNetwork + 392
    frame #16: 0x00000001923de8f0 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
    frame #17: 0x00000001923de7f0 CoreFoundation`__CFRunLoopDoSource0 + 204
    frame #18: 0x00000001923ddb44 CoreFoundation`__CFRunLoopDoSources0 + 256
    frame #19: 0x00000001923d8060 CoreFoundation`__CFRunLoopRun + 768
    frame #20: 0x00000001923d7818 CoreFoundation`CFRunLoopRunSpecific + 572
    frame #21: 0x0000000192c70ee8 CFNetwork`___lldb_unnamed_symbol11168$$CFNetwork + 548
    frame #22: 0x0000000193790db0 Foundation`__NSThread__start__ + 848
    frame #23: 0x00000001da983c74 libsystem_pthread.dylib`_pthread_start + 288

@tangbl93 分片大小和上传阈值有调整吗?看信息是内存不足,分配空间错误

@YangSen-qn 没有调整这些参数。关键代码如下:

dispatch_async(concurrent_queue,^{
    StrongSelf
    [strongSelf httpGetQiniuTokenIsPulic:NO block:^(NSString *qiniuToken) {
        @try {
            QNUploadOption * option = [[QNUploadOption alloc] initWithMime:nil progressHandler:^(NSString *key, float percent) {
                ...
            } params:nil checkCrc:false cancellationSignal:^BOOL{
                return strongSelf.cancelUpload;
            }];
            
            // QNUploadManager: 初始化
            // QNFileRecorder *recorder = [QNFileRecorder fileRecorderWithFolder:[NSTemporaryDirectory() stringByAppendingString:@"QiniuTemp"] error:&error];
            // _upManager = [[QNUploadManager alloc] initWithRecorder:recorder];

            [strongSelf->_upManager putFile:filePath key:fileKey token:qiniuToken complete:^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {
                strongSelf.uploding = false;
                ...
            } option:option];
            
        } @catch (NSException *exception) {
            
        } @finally {
            
        }
    }];        
});

@tangbl93 建议看看手机存储空间是否充足,清理下手机中非必须的文件以增大手机的剩余存储空间。