0

I added admob to my application.

If there is no internet connection the app will crash with the following error.

Phrasebook(2806,0x3196a28) malloc: *** error for object 0xc0e27a0: 
incorrect checksum for freed object - object was probably modified after being freed.
set a breakpoint in malloc_error_break to debug

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{

GADBannerView *bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];

bannerView_.adUnitID = MyAdUnitID;

// Let the runtime know which UIViewController to restore after taking
// the user wherever the ad goes and add it to the view hierarchy.
bannerView_.rootViewController = self;

// Initiate a generic request to load it with an ad.
[bannerView_ loadRequest:[GADRequest request]];
return bannerView_;
}

-(float)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
// admob ad size height
return 50.0;

}

I did set a break point in malloc_error_break, and this the backtrace

* thread #1: tid = 0x245a6, 0x03101875 libsystem_c.dylib`malloc_error_break, queue = 'com.apple.main-thread, stop reason = breakpoint 1.1
frame #0: 0x03101875 libsystem_c.dylib`malloc_error_break
frame #1: 0x0310a17a libsystem_c.dylib`szone_error + 270
frame #2: 0x0310b482 libsystem_c.dylib`free_list_checksum_botch + 50
frame #3: 0x0310b5ad libsystem_c.dylib`tiny_free_list_remove_ptr + 185
frame #4: 0x03105171 libsystem_c.dylib`szone_free + 1601
frame #5: 0x023622e8 CoreFoundation`__CFAllocatorSystemDeallocate + 24
frame #6: 0x023622b4 CoreFoundation`CFAllocatorDeallocate + 100
frame #7: 0x0236200e CoreFoundation`CFRelease + 1134
frame #8: 0x0000ebd0 Phrasebook`-[GADTiming dealloc] + 66
frame #9: 0x02174692 libobjc.A.dylib`objc_object::sidetable_release(bool) + 268
frame #10: 0x02175adf libobjc.A.dylib`-[NSObject release] + 25
frame #11: 0x000303af Phrasebook`-[GADAdFetcher dealloc] + 114
frame #12: 0x02174692 libobjc.A.dylib`objc_object::sidetable_release(bool) + 268
frame #13: 0x02173e81 libobjc.A.dylib`objc_release + 49
frame #14: 0x02160b44 libobjc.A.dylib`objc_setProperty_non_gc(objc_object*, objc_selector*, int, objc_object*, signed char, signed char) + 173
frame #15: 0x02160d3a libobjc.A.dylib`objc_setProperty + 47
frame #16: 0x00024614 Phrasebook`-[GADSlot setAdFetcher:] + 63
frame #17: 0x000216dd Phrasebook`-[GADSlot loadAdHTMLFromURL:usingActivationOverlayURL:] + 466
frame #18: 0x00022796 Phrasebook`-[GADSlot loadAdURL:] + 733
frame #19: 0x0003ff4b Phrasebook`-[GADJavaScriptController loadAdURL:] + 217
frame #20: 0x01e36bf9 Foundation`__57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke + 40
frame #21: 0x0243c524 CoreFoundation`__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
frame #22: 0x0239400b CoreFoundation`_CFXNotificationPost + 2859
frame #23: 0x01d70951 Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 98
frame #24: 0x0001c9d3 Phrasebook`-[GADNotificationCenter postNotificationFromURL:object:] + 126
frame #25: 0x0001ca42 Phrasebook`-[GADNotificationCenter delayedPosting:] + 103
frame #26: 0x01d9a12c Foundation`__NSFireDelayedPerform + 372
frame #27: 0x0239ebd6 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
frame #28: 0x0239e5bd CoreFoundation`__CFRunLoopDoTimer + 1181
frame #29: 0x02386628 CoreFoundation`__CFRunLoopRun + 1816
frame #30: 0x02385ac3 CoreFoundation`CFRunLoopRunSpecific + 467
frame #31: 0x023858db CoreFoundation`CFRunLoopRunInMode + 123
frame #32: 0x038209e2 GraphicsServices`GSEventRunModal + 192
frame #33: 0x03820809 GraphicsServices`GSEventRun + 104
frame #34: 0x00ed1d3b UIKit`UIApplicationMain + 1225
frame #35: 0x000056bd Phrasebook`main(argc=1, argv=0xbfffedf8) + 141 at main.m:16
frame #36: 0x03062725 libdyld.dylib`start + 1   

what would be the best solution for this issue, i thought about checking if there is an internet connection before using the local GADBannerView


testing it further i received this backtrace

(lldb) bt
* thread #4: tid = 0x455eb, 0x021730b2 libobjc.A.dylib`objc_msgSend + 14, name = 'WebThread, stop reason = EXC_BAD_ACCESS (code=2, address=0xc)
frame #0: 0x021730b2 libobjc.A.dylib`objc_msgSend + 14
frame #1: 0x05de1975 WebKit`WebFrameLoaderClient::cancelPolicyCheck() + 37
frame #2: 0x06a2927e WebCore`WebCore::PolicyChecker::stopCheck() + 30
frame #3: 0x062f6f1f WebCore`WebCore::FrameLoader::loadWithDocumentLoader(WebCore::DocumentLoader*, WebCore::FrameLoadType, WTF::PassRefPtr<WebCore::FormState>) + 495
frame #4: 0x062f610d WebCore`WebCore::FrameLoader::loadWithNavigationAction(WebCore::ResourceRequest const&, WebCore::NavigationAction const&, bool, WebCore::FrameLoadType, WTF::PassRefPtr<WebCore::FormState>) + 573
frame #5: 0x062f3c61 WebCore`WebCore::FrameLoader::loadURL(WebCore::KURL const&, WTF::String const&, WTF::String const&, bool, WebCore::FrameLoadType, WTF::PassRefPtr<WebCore::Event>, WTF::PassRefPtr<WebCore::FormState>) + 1297
frame #6: 0x062ef1c2 WebCore`WebCore::FrameLoader::loadFrameRequest(WebCore::FrameLoadRequest const&, bool, bool, WTF::PassRefPtr<WebCore::Event>, WTF::PassRefPtr<WebCore::FormState>, WebCore::ShouldSendReferrer) + 722
frame #7: 0x062ee980 WebCore`WebCore::FrameLoader::urlSelected(WebCore::FrameLoadRequest const&, WTF::PassRefPtr<WebCore::Event>, bool, bool, WebCore::ShouldSendReferrer, WebCore::ShouldReplaceDocumentIfJavaScriptURL) + 336
frame #8: 0x062ee6a2 WebCore`WebCore::FrameLoader::changeLocation(WebCore::SecurityOrigin*, WebCore::KURL const&, WTF::String const&, bool, bool, bool) + 178
frame #9: 0x069e2d8a WebCore`WebCore::ScheduledURLNavigation::fire(WebCore::Frame*) + 122
frame #10: 0x069e1913 WebCore`WebCore::NavigationScheduler::timerFired(WebCore::Timer<WebCore::NavigationScheduler>*) + 99
frame #11: 0x069e2717 WebCore`WebCore::Timer<WebCore::NavigationScheduler>::fired() + 39
frame #12: 0x06deed40 WebCore`WebCore::ThreadTimers::sharedTimerFiredInternal() + 192
frame #13: 0x06deebd6 WebCore`WebCore::ThreadTimers::sharedTimerFired() + 22
frame #14: 0x06c3f37b WebCore`WebCore::timerFired(__CFRunLoopTimer*, void*) + 27
frame #15: 0x0239ebd6 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
frame #16: 0x0239e5bd CoreFoundation`__CFRunLoopDoTimer + 1181
frame #17: 0x02386628 CoreFoundation`__CFRunLoopRun + 1816
frame #18: 0x02385ac3 CoreFoundation`CFRunLoopRunSpecific + 467
frame #19: 0x023858db CoreFoundation`CFRunLoopRunInMode + 123
frame #20: 0x06e50f00 WebCore`RunWebThread(void*) + 608
frame #21: 0x030e85b7 libsystem_c.dylib`_pthread_start + 344
B.I.A
  • 702
  • 1
  • 7
  • 19
  • I'm also getting admob crashes with their latest SDK, will be doing a patch release with a rollback to the previous static library. – jjxtra Jan 08 '14 at 18:22
  • @PsychoDad thanks, solution i used is slow, specially when changing views – B.I.A Jan 10 '14 at 13:07
  • I'd suggest just rolling back your admob library. It doesn't crash if no internet. – jjxtra Jan 10 '14 at 15:03

2 Answers2

0

i ended up checking for internet connectivity, taken from this answer .

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
     // bing.com load faster than google.com
     NSURL *scriptUrl = [NSURL URLWithString:@"http://www.bing.com"];
     NSData *data = [NSData dataWithContentsOfURL:scriptUrl];
     if (data){
         // Device is connected to the internet
         GADBannerView  *bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];

         // Specify the ad's "unit identifier." This is your AdMob Publisher ID.
         bannerView_.adUnitID = MyAdUnitID;

         // Let the runtime know which UIViewController to restore after taking
         // the user wherever the ad goes and add it to the view hierarchy.
         bannerView_.rootViewController = self;

         // Initiate a generic request to load it with an ad.
         [bannerView_ loadRequest:[GADRequest request]];
         return bannerView_;

     }else{

         // Device is not connected to the internet
         UIView *emptyView = [[UIView alloc] init];
         return emptyView;

     }
}
Community
  • 1
  • 1
B.I.A
  • 702
  • 1
  • 7
  • 19
0

UPDATE: my crash is fixed with Google Mobile Ads SDK 6.8.0 for iOS that they just released.

I'm also seeing this with Google Mobile Ads SDK 6.7.0 for iOS.

A work around that appears to be working is in your

(void)adView:(GADBannerView *)bannerView didFailToReceiveAdWithError:(GADRequestError *)error;

remove the bannerAdView from the superview, alloc and set up a new one.

See https://groups.google.com/forum/#!searchin/google-admob-ads-sdk/crash$20airplane/google-admob-ads-sdk/tSgHL7X0aWU/jNvm5_SO6iwJ for details

Seth Spitzer
  • 76
  • 1
  • 5