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

crash #155

Open
RichAPMIOS opened this issue Mar 16, 2017 · 0 comments
Open

crash #155

RichAPMIOS opened this issue Mar 16, 2017 · 0 comments

Comments

@RichAPMIOS
Copy link

use an NSURLProtocol subclass to intercept the HTTP/HTTPS requests,then i save http request use model,model has a nettype property.

- (NSString *)netType {
    
    Reachability *reachability = [Reachability reachabilityForInternetConnection];
    [reachability startNotifier];
    NetworkStatus status = [reachability currentReachabilityStatus];
    
    if(status == NotReachable)
    {
        return InfoUnknown;
        //No internet
    }
    else if (status == ReachableViaWiFi)
    {
        return @"wifi";
        //WiFi
    }else if (status == ReachableViaWWAN) {
    
        NSArray *typeStrings2G = @[CTRadioAccessTechnologyEdge,
                                   CTRadioAccessTechnologyGPRS,
                                   CTRadioAccessTechnologyCDMA1x];
        
        NSArray *typeStrings3G = @[CTRadioAccessTechnologyHSDPA,
                                   CTRadioAccessTechnologyWCDMA,
                                   CTRadioAccessTechnologyHSUPA,
                                   CTRadioAccessTechnologyCDMAEVDORev0,
                                   CTRadioAccessTechnologyCDMAEVDORevA,
                                   CTRadioAccessTechnologyCDMAEVDORevB,
                                   CTRadioAccessTechnologyeHRPD];
        
        NSArray *typeStrings4G = @[CTRadioAccessTechnologyLTE];
        
        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
        {
            CTTelephonyNetworkInfo *teleInfo= [[CTTelephonyNetworkInfo alloc] init];
            NSString *accessString = teleInfo.currentRadioAccessTechnology;
            if ([typeStrings4G containsObject:accessString]) {
                return @"4g";
            } else if ([typeStrings3G containsObject:accessString]) {
                return @"3g";
            } else if ([typeStrings2G containsObject:accessString]) {
                return @"2g";
            } else {
                return InfoUnknown;
            }
        } ;
        return InfoUnknown;
    
        
     }
    return InfoUnknown;
}

occasionally crash

Browser(10599,0x700005871000) malloc: *** error for object 0x7fd292e4bfd8: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
(lldb) bt
* thread #19: tid = 0x5ea3f, 0x00000001106d4bf7 libsystem_malloc.dylib`malloc_error_break, name = 'com.apple.CFNetwork.CustomProtocols', stop reason = breakpoint 2.1
    frame #0: 0x00000001106d4bf7 libsystem_malloc.dylib`malloc_error_break
    frame #1: 0x00000001106cd515 libsystem_malloc.dylib`szone_error + 406
    frame #2: 0x00000001106defe4 libsystem_malloc.dylib`tiny_malloc_from_free_list + 1148
    frame #3: 0x00000001106cdfbb libsystem_malloc.dylib`szone_malloc_should_clear + 497
    frame #4: 0x00000001106d5d3f libsystem_malloc.dylib`malloc_zone_calloc + 87
    frame #5: 0x00000001106d60f8 libsystem_malloc.dylib`calloc + 30
    frame #6: 0x0000000109471340 libobjc.A.dylib`class_createInstance + 85
    frame #7: 0x00000001104b29de libdispatch.dylib`_os_object_alloc + 60
    frame #8: 0x00000001106fddef libsystem_network.dylib`nw_parameters_copy_inner + 58
    frame #9: 0x0000000110715b48 libsystem_network.dylib`nw_path_copy_derived_parameters + 37
    frame #10: 0x0000000108c7be31 SystemConfiguration`__SCNetworkReachabilitySetDispatchQueue + 907
    frame #11: 0x0000000108c7c1a6 SystemConfiguration`SCNetworkReachabilitySetDispatchQueue + 107
    frame #12: 0x00000001082aa434 Browser`-[Reachability startNotifier](self=0x0000600001065640, _cmd="startNotifier") + 340 at Reachability.m:200
  * frame #13: 0x00000001082b29b2 Browser`-[DeviceInfo netType](self=0x0000600000033d00, _cmd="netType") + 98 at DeviceInfo.m:234
    frame #14: 0x00000001082f6119 Browser`-[HTTPModel setupExtraData](self=0x000060000038bfc0, _cmd="setupExtraData") + 73 at HTTPModel.m:177
    frame #15: 0x00000001082e4b69 Browser`-[HTTPProtocol startLoading](self=0x000060000049f950, _cmd="startLoading") + 1433 at HTTPProtocol.m:161
    frame #16: 0x000000010c6d41b2 CFNetwork`___ZN16CFURLProtocol_NS28_protocolInterface_startLoadEPK20_CFCachedURLResponse_block_invoke + 307
    frame #17: 0x00000001104b30cd libdispatch.dylib`_dispatch_client_callout + 8
    frame #18: 0x000000011048d9f7 libdispatch.dylib`_dispatch_block_invoke_direct + 567
    frame #19: 0x000000010c5a0eac CFNetwork`RunloopBlockContext::_invoke_block(void const*, void*) + 24
    frame #20: 0x0000000109d74014 CoreFoundation`CFArrayApplyFunction + 68
    frame #21: 0x000000010c5a0da5 CFNetwork`RunloopBlockContext::perform() + 137
    frame #22: 0x000000010c5a0c3e CFNetwork`MultiplexerSource::perform() + 282
    frame #23: 0x000000010c5a0a60 CFNetwork`MultiplexerSource::_perform(void*) + 72
    frame #24: 0x0000000109dc8311 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    frame #25: 0x0000000109dad59c CoreFoundation`__CFRunLoopDoSources0 + 556
    frame #26: 0x0000000109daca86 CoreFoundation`__CFRunLoopRun + 918
    frame #27: 0x0000000109dac494 CoreFoundation`CFRunLoopRunSpecific + 420
    frame #28: 0x000000010c841082 CFNetwork`_privateRunloopEmulationSet(void*) + 258
    frame #29: 0x000000011085baab libsystem_pthread.dylib`_pthread_body + 180
    frame #30: 0x000000011085b9f7 libsystem_pthread.dylib`_pthread_start + 286
    frame #31: 0x000000011085b1fd libsystem_pthread.dylib`thread_start + 13
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

1 participant