ios - GCD dispatch_async DISPATCH_QUEUE_PRIORITY_DEFAULT EXC_BAD_ACCESS crash -
i want write log file in global default queue. works in ios 6 crash in ios 5 if block empty.
dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default, 0), ^{ //fprintf(s_logfp, "[%s] %s\n", [[[nsdate date] hipuclientlogdescription] utf8string], [log utf8string]); });
it goes right if code this:
logqueue = dispatch_queue_create("com.hipu.clientlog", null); dispatch_async(logqueue, ^{ fprintf(s_logfp, "[%s] %s\n", [[[nsdate date] hipuclientlogdescription] utf8string], [log utf8string]); });
call stack:
#0 0x01dff0b0 in objc_msgsend () #1 0x01dffd40 in objc_retain () #2 0x0044a712 in hpwritelogtodisk @ /users/tanqiyu/documents/hipu_work/ios/trunk/hipuclient/hpfoundation/hpfoundation/hplog.m:60 #3 0x003420b6 in -[hpengine initwithrootdir:appversion:] @ /users/tanqiyu/documents/hipu_work/ios/trunk/hipuclient/hpengine/hpengine/engine/hpengine.m:69 #4 0x00341a8d in +[hpengine initenginewithrootdir:appversion:] @ /users/tanqiyu/documents/hipu_work/ios/trunk/hipuclient/hpengine/hpengine/engine/hpengine.m:28 #5 0x0000abcd in -[appdelegate application:didfinishlaunchingwithoptions:] @ /users/tanqiyu/documents/hipu_work/ios/trunk/hipuclient/hipuclient/hipuclient/appdelegate.m:35 #6 0x00f5a9d6 in -[uiapplication _callinitializationdelegatesforurl:payload:suspended:] () #7 0x00f5b8a6 in -[uiapplication _runwithurl:payload:launchorientation:statusbarstyle:statusbarhidden:] () #8 0x00f6a743 in -[uiapplication handleevent:withnewevent:] () #9 0x00f6b1f8 in -[uiapplication sendevent:] () #10 0x00f5eaa9 in _uiapplicationhandleevent () #11 0x02325fa9 in purpleeventcallback () #12 0x021661c5 in __cfrunloop_is_calling_out_to_a_source1_perform_function__ () #13 0x020cb022 in __cfrunloopdosource1 () #14 0x020c990a in __cfrunlooprun () #15 0x020c8db4 in cfrunlooprunspecific () #16 0x020c8ccb in cfrunloopruninmode () #17 0x00f5b2a7 in -[uiapplication _run] () #18 0x00f5ca9b in uiapplicationmain () #19 0x0000a97d in main @
if crashes no code in block surely corrupting memory.
when fix that:
1) insure slogfp global , not change.
2) if either string nil crash trying use char* nil. suggest create 1 nsstring first, test valid, dispatch logging.
Comments
Post a Comment