Re: How to debug crash in NSOperation?

2017-03-26 Thread Gerriet M. Denkmann

> On 27 Mar 2017, at 10:39, Ken Thomases  wrote:
> 
> On Mar 26, 2017, at 10:06 PM, Gerriet M. Denkmann  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   0x7fffb3d65dd6 __pthread_kill + 10
>> 1   libsystem_pthread.dylib  0x7fffb3e51787 pthread_kill + 90
>> 2   libsystem_c.dylib0x7fffb3ccb420 abort + 129
>> 3   libc++abi.dylib  0x7fffb282885a abort_message + 266
>> 4   libc++abi.dylib  0x7fffb284dc4f 
>> default_terminate_handler() + 267
>> 5   libobjc.A.dylib  0x7fffb3357b8e _objc_terminate() + 
>> 103
>> 6   libc++abi.dylib  0x7fffb284ad69 
>> std::__terminate(void (*)()) + 8
>> 7   libc++abi.dylib  0x7fffb284ade3 std::terminate() + 51
>> 8   libdispatch.dylib0x7fffb3c010cc 
>> _dispatch_client_callout + 28
>> 9   libdispatch.dylib0x7fffb3c17ae5 
>> _dispatch_queue_serial_drain + 896
>> 10  libdispatch.dylib0x7fffb3c09cd9 
>> _dispatch_queue_invoke + 1046
>> 11  libdispatch.dylib0x7fffb3c02e70 
>> _dispatch_root_queue_drain + 476
>> 12  libdispatch.dylib0x7fffb3c02c47 
>> _dispatch_worker_thread3 + 99
>> 13  libsystem_pthread.dylib  0x7fffb3e4e712 _pthread_wqthread + 
>> 1299
>> 14  libsystem_pthread.dylib  0x7fffb3e4e1ed 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  0x7fff9e6c40db 
__exceptionPreprocess + 171
1   libobjc.A.dylib 0x7fffb3355a2a objc_exception_throw 
+ 48
2   CoreFoundation  0x7fff9e5c4115 -[__NSDictionaryM 
setObject:forKey:] + 1061
3   Foundation  0x7fffa02bf805 -[NSRTFD 
setObject:forKey:] + 257
4   Foundation  0x7fffa02b94ee -[NSFileWrapper 
_newImpl] + 573
5   Foundation  0x7fffa02b9811 -[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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: How to debug crash in NSOperation?

2017-03-26 Thread Ken Thomases
On Mar 26, 2017, at 10:06 PM, Gerriet M. Denkmann  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.dylib0x7fffb3d65dd6 __pthread_kill + 10
> 1   libsystem_pthread.dylib   0x7fffb3e51787 pthread_kill + 90
> 2   libsystem_c.dylib 0x7fffb3ccb420 abort + 129
> 3   libc++abi.dylib   0x7fffb282885a abort_message + 266
> 4   libc++abi.dylib   0x7fffb284dc4f 
> default_terminate_handler() + 267
> 5   libobjc.A.dylib   0x7fffb3357b8e _objc_terminate() + 
> 103
> 6   libc++abi.dylib   0x7fffb284ad69 
> std::__terminate(void (*)()) + 8
> 7   libc++abi.dylib   0x7fffb284ade3 std::terminate() + 51
> 8   libdispatch.dylib 0x7fffb3c010cc 
> _dispatch_client_callout + 28
> 9   libdispatch.dylib 0x7fffb3c17ae5 
> _dispatch_queue_serial_drain + 896
> 10  libdispatch.dylib 0x7fffb3c09cd9 
> _dispatch_queue_invoke + 1046
> 11  libdispatch.dylib 0x7fffb3c02e70 
> _dispatch_root_queue_drain + 476
> 12  libdispatch.dylib 0x7fffb3c02c47 
> _dispatch_worker_thread3 + 99
> 13  libsystem_pthread.dylib   0x7fffb3e4e712 _pthread_wqthread + 
> 1299
> 14  libsystem_pthread.dylib   0x7fffb3e4e1ed 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?

Regards,
Ken


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

How to debug crash in NSOperation?

2017-03-26 Thread Gerriet M. Denkmann
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  0x7fffb3d65dd6 __pthread_kill + 10
1   libsystem_pthread.dylib 0x7fffb3e51787 pthread_kill + 90
2   libsystem_c.dylib   0x7fffb3ccb420 abort + 129
3   libc++abi.dylib 0x7fffb282885a abort_message + 266
4   libc++abi.dylib 0x7fffb284dc4f 
default_terminate_handler() + 267
5   libobjc.A.dylib 0x7fffb3357b8e _objc_terminate() + 
103
6   libc++abi.dylib 0x7fffb284ad69 
std::__terminate(void (*)()) + 8
7   libc++abi.dylib 0x7fffb284ade3 std::terminate() + 51
8   libdispatch.dylib   0x7fffb3c010cc 
_dispatch_client_callout + 28
9   libdispatch.dylib   0x7fffb3c17ae5 
_dispatch_queue_serial_drain + 896
10  libdispatch.dylib   0x7fffb3c09cd9 
_dispatch_queue_invoke + 1046
11  libdispatch.dylib   0x7fffb3c02e70 
_dispatch_root_queue_drain + 476
12  libdispatch.dylib   0x7fffb3c02c47 
_dispatch_worker_thread3 + 99
13  libsystem_pthread.dylib 0x7fffb3e4e712 _pthread_wqthread + 
1299
14  libsystem_pthread.dylib 0x7fffb3e4e1ed start_wqthread + 13

The NSOperationQueue named “ เสือ" is created at the start of the app thusly:

@interface EchoStreamServer()   
@property (strong)  NSOperationQueue*commandOperationQueue;
@end

@implementation EchoStreamServer

- (instancetype)initWithInputStream: (NSInputStream *)istr  
outputStream:(NSOutputStream *)ostr  owner: (id )oo  security: 
securityThing  service: (NSNetService *)svice;
{
self =  [ super initWithInputStream:istr   …. ];
if ( self == nil ) return nil;  

_commandOperationQueue = [ [ NSOperationQueue alloc ] init ];
_commandOperationQueue.name = @"เสือ";
_commandOperationQueue.qualityOfService = [ oo echoQualityOfService ];  
//  NSQualityOfServiceUtility

return self;
}

//  this is called as answer to a request from a client:
- (void)sendToOwnerObject: obb  seqNbr: (NSUInteger)seqNbr; 
{   
if ( self.owner == nil )….  //  error

NSBlockOperation *echoOperation = [ [ NSBlockOperation alloc ] init ];
__weak NSBlockOperation *weakBo = echoOperation;

[ echoOperation addExecutionBlock: ^void(void)
{   [ self.ownerechoObject: obb  
seqNbr: seqNbr  
from:   self  
operation:  weakBo 
]; 
} 
];

[ self.commandOperationQueue  addOperation: echoOperation ];
}

// this probably is never called:
- (void)cancelEchoOperations: (BOOL)explicit;
{
[ self.commandOperationQueue  cancelAllOperations ];
…
}

Any ideas how to debug this?

Gerriet.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Official sidebar?

2017-03-26 Thread Saagar Jha
Yes, there is an API for them; it’s part of NSWindow 
. The basic tabbing is 
done by default, but there is the option to turn it on/off, get a list of 
tabbed windows, and manually add one to the list.

Saagar Jha

> On Mar 25, 2017, at 23:53, Jens Alfke  wrote:
> 
> 
>> On Mar 25, 2017, at 4:40 PM, Saagar Jha > > wrote:
>> 
>> Nothing, if I remember correctly. Cocoa should handle window tabs for you.
> 
> Isn’t there an API to manage them? 
> 
> For example, I use the tab bar in SourceTree to group multiple repositories 
> into a single window, but every time I relaunch the app, they reopen as 
> separate windows and I have to group them again. I was assuming there’s an 
> API apps could adopt to be more aware of the tabs and at least be able to 
> restore them.
> 
> —Jens

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Official sidebar?

2017-03-26 Thread Jean-Daniel
The OP ask about « Side Bar » not  «  Tab Bar ».

> Le 26 mars 2017 à 00:40, Saagar Jha  a écrit :
> 
> Nothing, if I remember correctly. Cocoa should handle window tabs for you.
> 
> Saagar Jha
> 
>> On Mar 25, 2017, at 07:49, Daryle Walker  wrote:
>> 
>> Testing out my app. Finally noticed the new "Show Tab Bar" View menu item. 
>> The menu also handles the tool bar, full screen, and a sidebar. Never 
>> noticed that last one before. What do I have to do in my storyboard and/or 
>> window controller to support that?
>> 
>> (Of course, I don't need one right now. But I'm still curious.)
>> 
>> Sent from my iPhone
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> 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:
>> https://lists.apple.com/mailman/options/cocoa-dev/saagar%40saagarjha.com
>> 
>> This email sent to saa...@saagarjha.com
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/mailing%40xenonium.com
> 
> This email sent to mail...@xenonium.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com