Re: How to debug crash in NSOperation?
Re: How to debug crash in NSOperation?
- Subject: Re: How to debug crash in NSOperation?
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Mon, 27 Mar 2017 12:04:44 +0700
> On 27 Mar 2017, at 10:39, Ken Thomases <email@hidden> wrote:
>
> On Mar 26, 2017, at 10:06 PM, Gerriet M. Denkmann <email@hidden> wrote:
>>
>> macOS 12.3
>>
>> This is a rather rare bug (never seen before):
>>
>> Thread 12 Crashed:: Dispatch queue: เสือ :: NSOperation 0x61800184fbd0 (QOS: UTILITY)
>> 0 libsystem_kernel.dylib 0x00007fffb3d65dd6 __pthread_kill + 10
>> 1 libsystem_pthread.dylib 0x00007fffb3e51787 pthread_kill + 90
>> 2 libsystem_c.dylib 0x00007fffb3ccb420 abort + 129
>> 3 libc++abi.dylib 0x00007fffb282885a abort_message + 266
>> 4 libc++abi.dylib 0x00007fffb284dc4f default_terminate_handler() + 267
>> 5 libobjc.A.dylib 0x00007fffb3357b8e _objc_terminate() + 103
>> 6 libc++abi.dylib 0x00007fffb284ad69 std::__terminate(void (*)()) + 8
>> 7 libc++abi.dylib 0x00007fffb284ade3 std::terminate() + 51
>> 8 libdispatch.dylib 0x00007fffb3c010cc _dispatch_client_callout + 28
>> 9 libdispatch.dylib 0x00007fffb3c17ae5 _dispatch_queue_serial_drain + 896
>> 10 libdispatch.dylib 0x00007fffb3c09cd9 _dispatch_queue_invoke + 1046
>> 11 libdispatch.dylib 0x00007fffb3c02e70 _dispatch_root_queue_drain + 476
>> 12 libdispatch.dylib 0x00007fffb3c02c47 _dispatch_worker_thread3 + 99
>> 13 libsystem_pthread.dylib 0x00007fffb3e4e712 _pthread_wqthread + 1299
>> 14 libsystem_pthread.dylib 0x00007fffb3e4e1ed start_wqthread + 13
>
> I would expect that some message would be logged to the system log at the time of the crash and/or included in the crash report, just above the thread backtraces. Was there such a message? If so, what was it?
Yes, you are right. And I have to apologise for not spotting this:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: SortedKeys.plist)'
abort() called
and the really relevant backtrace is:
Application Specific Backtrace 1:
0 CoreFoundation 0x00007fff9e6c40db __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fffb3355a2a objc_exception_throw + 48
2 CoreFoundation 0x00007fff9e5c4115 -[__NSDictionaryM setObject:forKey:] + 1061
3 Foundation 0x00007fffa02bf805 -[NSRTFD setObject:forKey:] + 257
4 Foundation 0x00007fffa02b94ee -[NSFileWrapper _newImpl] + 573
5 Foundation 0x00007fffa02b9811 -[NSFileWrapper serializedRepresentation] + 37
…
My app does (in some non-main thread used by my Dispatch queue: เสือ):
NSString *directoryPath = …
… write some files to directoryPath and finally do:
[ arrayOfStrings writeToFile: “directoryPath/SortedKeys.plist” atomically: YES ]; ← pseudo code
NSURL *url = [ NSURL fileURLWithPath: directoryPath isDirectory: YES ];
NSFileWrapper *fw = [ [ NSFileWrapper alloc ] initWithURL: url options: 0 error: &outError ];
… remove a few subwrappers from fw …
NSData *dataIn = fw.serializedRepresentation; ← crashed here
I suspect that this might be a rare timing issue, i.e. SortedKeys.plist has not been fully written when serializedRepresentation is called.
Any ideas how this could be avoided?
Kind regards,
Gerriet.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden