Re: WTF is happening?
During the course of this thread, Maxthon has given us code that would enable us to run the experiment for ourselves. I do not doubt him. — Charles Jenkins On Monday, December 15, 2014 at 2:31 AM, Maxthon Chan wrote: My class scanning returned several OS* classes that does not conform to NSObject protocol. On Dec 15, 2014, at 00:29, Clark S. Cox III clarkc...@gmail.com (mailto:clarkc...@gmail.com) wrote: On Dec 13, 2014, at 11:57, Maxthon Chan m...@maxchan.info mailto:m...@maxchan.info wrote: NSProxy checking actually work, but throwing those classes that derive from Object class (note I used capitalised O here, the old Object class from early NeXT times, also used heavily in OS X kernel, GCD and Mach ports) What makes you think that Object is used in *any* of those places? into the mix means that no method can be sent before class is determined. I would suggest Apple add one runtime function class_isSubclassOfClass() that mirrors the functionality of NSObject and NSProxy method isSubclassOfClass so that derivatives of the old Object class can be detected more easily. On Dec 14, 2014, at 03:49, Gary L. Wade garyw...@desisoftsystems.com (mailto:garyw...@desisoftsystems.com) wrote: Are you saying that Apple's well-documented approach to see if an object is derived from NSProxy does not work? If that's the case, you need to submit a bug report to Apple. That's a serious issue that only Apple can help you with. If you are using objects not derived from NSObject nor NSProxy, then change your design. -- Gary L. Wade (Sent from my iPad) http://www.garywade.com/ On Dec 13, 2014, at 11:40 AM, Maxthon Chan m...@maxchan.info (mailto:m...@maxchan.info) wrote: Ain’t work! Will crash if an Object derivative showed up. I am scanning ALL loaded classes and only subclasses of a certain class is interested. But due to the nature of this class scanning before I can make sure that the class derives from NSObject I cannot call any method on it. On Dec 14, 2014, at 03:34, Gary L. Wade garyw...@desisoftsystems.com (mailto:garyw...@desisoftsystems.com) wrote: If all you care about is if an object is a proxy or not, look at isProxy. -- Gary L. Wade (Sent from my iPad) http://www.garywade.com/ On Dec 13, 2014, at 11:06 AM, Maxthon Chan m...@maxchan.info (mailto:m...@maxchan.info) wrote: What I am doing here is scanning all loaded classes for subclasses of a certain class. Before any NSObject method can be issued I have to check if it is actually NSObject or NSProxy derivative instead of an Object derivative that does not support NSObject methods. This calls for runtime equivalent for one of the following NSObject methods: - [NSObject respondsToSelector:(SEL)aSelector] = class_respondsToSelector(Class, SEL) // this crashed. + [NSObject conformsToProtocol:(Protocol *)aProtocol] = class_conformsToProtocol(Class, Protocol *) // check for NSObject protocol, this does not work. + [NSObject isSubclassOfClass:(Class)aClass] // no equivalent, have to implement it myself I ended up creating this: BOOL class_isSubclassOfClass(Class cls, Class other) { for (Class c = cls; c; c = class_getSuperclass(c)) if (c == other) return YES; return NO; } If i remembered it right GNUstep runtime have this function. I will file a bug report to Apple and ask them to add this, as it is useful in class scanning and i am using this technique heavily in jailbreak detection. On Dec 14, 2014, at 01:20, Kyle Sluder k...@ksluder.com (mailto:k...@ksluder.com) wrote: On Sat, Dec 13, 2014, at 10:19 AM, Phillip Mills wrote: Why do you think the problem is with “respondsToSelector:”? The error says you’re accessing past the end of a string. Because the crash happens in a call stack that originates in class_respondsToSelector, and involves none of Maxthon's code. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com mailto: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 http://lists.apple.com/ Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com https://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com This email sent to
Re: WTF is happening?
I found only 5 classes that does not responds to isProxy and they are all internal classes, so real code will never have to deal with instances of such classes. And all classes prefixed by « OS_ » inherits NSObject and responds to isProxy. I run the experiment for myself and do not doubt the result. Le 15 déc. 2014 à 12:12, Charles Jenkins cejw...@gmail.com a écrit : During the course of this thread, Maxthon has given us code that would enable us to run the experiment for ourselves. I do not doubt him. — Charles Jenkins On Monday, December 15, 2014 at 2:31 AM, Maxthon Chan wrote: My class scanning returned several OS* classes that does not conform to NSObject protocol. On Dec 15, 2014, at 00:29, Clark S. Cox III clarkc...@gmail.com (mailto:clarkc...@gmail.com) wrote: On Dec 13, 2014, at 11:57, Maxthon Chan m...@maxchan.info mailto:m...@maxchan.info wrote: NSProxy checking actually work, but throwing those classes that derive from Object class (note I used capitalised O here, the old Object class from early NeXT times, also used heavily in OS X kernel, GCD and Mach ports) What makes you think that Object is used in *any* of those places? into the mix means that no method can be sent before class is determined. I would suggest Apple add one runtime function class_isSubclassOfClass() that mirrors the functionality of NSObject and NSProxy method isSubclassOfClass so that derivatives of the old Object class can be detected more easily. On Dec 14, 2014, at 03:49, Gary L. Wade garyw...@desisoftsystems.com (mailto:garyw...@desisoftsystems.com) wrote: Are you saying that Apple's well-documented approach to see if an object is derived from NSProxy does not work? If that's the case, you need to submit a bug report to Apple. That's a serious issue that only Apple can help you with. If you are using objects not derived from NSObject nor NSProxy, then change your design. -- Gary L. Wade (Sent from my iPad) http://www.garywade.com/ On Dec 13, 2014, at 11:40 AM, Maxthon Chan m...@maxchan.info (mailto:m...@maxchan.info) wrote: Ain’t work! Will crash if an Object derivative showed up. I am scanning ALL loaded classes and only subclasses of a certain class is interested. But due to the nature of this class scanning before I can make sure that the class derives from NSObject I cannot call any method on it. On Dec 14, 2014, at 03:34, Gary L. Wade garyw...@desisoftsystems.com (mailto:garyw...@desisoftsystems.com) wrote: If all you care about is if an object is a proxy or not, look at isProxy. -- Gary L. Wade (Sent from my iPad) http://www.garywade.com/ On Dec 13, 2014, at 11:06 AM, Maxthon Chan m...@maxchan.info (mailto:m...@maxchan.info) wrote: What I am doing here is scanning all loaded classes for subclasses of a certain class. Before any NSObject method can be issued I have to check if it is actually NSObject or NSProxy derivative instead of an Object derivative that does not support NSObject methods. This calls for runtime equivalent for one of the following NSObject methods: - [NSObject respondsToSelector:(SEL)aSelector] = class_respondsToSelector(Class, SEL) // this crashed. + [NSObject conformsToProtocol:(Protocol *)aProtocol] = class_conformsToProtocol(Class, Protocol *) // check for NSObject protocol, this does not work. + [NSObject isSubclassOfClass:(Class)aClass] // no equivalent, have to implement it myself I ended up creating this: BOOL class_isSubclassOfClass(Class cls, Class other) { for (Class c = cls; c; c = class_getSuperclass(c)) if (c == other) return YES; return NO; } If i remembered it right GNUstep runtime have this function. I will file a bug report to Apple and ask them to add this, as it is useful in class scanning and i am using this technique heavily in jailbreak detection. On Dec 14, 2014, at 01:20, Kyle Sluder k...@ksluder.com (mailto:k...@ksluder.com) wrote: On Sat, Dec 13, 2014, at 10:19 AM, Phillip Mills wrote: Why do you think the problem is with “respondsToSelector:”? The error says you’re accessing past the end of a string. Because the crash happens in a call stack that originates in class_respondsToSelector, and involves none of Maxthon's code. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com mailto: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 http://lists.apple.com/ Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com https://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com This email sent to clarkc...@gmail.com mailto:clarkc...@gmail.com ___ Cocoa-dev mailing list
Re: WTF is happening?
On 15 Dec 2014, at 12:42, Jean-Daniel Dupas mail...@xenonium.com wrote: I found only 5 classes that does not responds to isProxy and they are all internal classes, so real code will never have to deal with instances of such classes. Maxthon is iterating over the classes in the system. Even internal classes to the OS show up in that list, so I really don't see how he would *not* have to be able to at least deal with their presence. Apart from completely re-thinking his approach. E.g. NSImageRep, AFAIK, simply has each image representation subclass add itself to an NSArray from its +initialize method. I'd think that'd be less fragile than walking the entire class list. -- Uli ___ 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: WTF is happening?
Le 15 déc. 2014 à 13:31, Uli Kusterer witness.of.teacht...@gmx.net a écrit : On 15 Dec 2014, at 12:42, Jean-Daniel Dupas mail...@xenonium.com wrote: I found only 5 classes that does not responds to isProxy and they are all internal classes, so real code will never have to deal with instances of such classes. Maxthon is iterating over the classes in the system. Even internal classes to the OS show up in that list, so I really don't see how he would *not* have to be able to at least deal with their presence. Fair enough, but I didn’t got any issue while dealing with theses classes. I managed to query if they responds to a selector, got there superclass and more. Apart from completely re-thinking his approach. E.g. NSImageRep, AFAIK, simply has each image representation subclass add itself to an NSArray from its +initialize method. I'd think that'd be less fragile than walking the entire class list. I fully agree on that. Relying on class iteration is generally a design flaw. It is too fragile to be used in a reliable and futur proof way. But I don’t think you can rely on +initialize to register subclasses as initialize will not be called until the someone try to use the target class (or one of it’s subclass). You can use +load but should probably be careful when doing so as there is no guarantee about the class loading order AFAIK. ___ 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: WTF is happening?
That does not mean that they're using Object only that they're using a base class other than NSObject or NSProxy. Why can't you just ignore such classes? Sent from my iPhone On Dec 14, 2014, at 23:31, Maxthon Chan m...@maxchan.info wrote: My class scanning returned several OS* classes that does not conform to NSObject protocol. On Dec 15, 2014, at 00:29, Clark S. Cox III clarkc...@gmail.com wrote: On Dec 13, 2014, at 11:57, Maxthon Chan m...@maxchan.info wrote: NSProxy checking actually work, but throwing those classes that derive from Object class (note I used capitalised O here, the old Object class from early NeXT times, also used heavily in OS X kernel, GCD and Mach ports) What makes you think that Object is used in *any* of those places? into the mix means that no method can be sent before class is determined. I would suggest Apple add one runtime function class_isSubclassOfClass() that mirrors the functionality of NSObject and NSProxy method isSubclassOfClass so that derivatives of the old Object class can be detected more easily. On Dec 14, 2014, at 03:49, Gary L. Wade garyw...@desisoftsystems.com wrote: Are you saying that Apple's well-documented approach to see if an object is derived from NSProxy does not work? If that's the case, you need to submit a bug report to Apple. That's a serious issue that only Apple can help you with. If you are using objects not derived from NSObject nor NSProxy, then change your design. -- Gary L. Wade (Sent from my iPad) http://www.garywade.com/ On Dec 13, 2014, at 11:40 AM, Maxthon Chan m...@maxchan.info wrote: Ain’t work! Will crash if an Object derivative showed up. I am scanning ALL loaded classes and only subclasses of a certain class is interested. But due to the nature of this class scanning before I can make sure that the class derives from NSObject I cannot call any method on it. On Dec 14, 2014, at 03:34, Gary L. Wade garyw...@desisoftsystems.com wrote: If all you care about is if an object is a proxy or not, look at isProxy. -- Gary L. Wade (Sent from my iPad) http://www.garywade.com/ On Dec 13, 2014, at 11:06 AM, Maxthon Chan m...@maxchan.info wrote: What I am doing here is scanning all loaded classes for subclasses of a certain class. Before any NSObject method can be issued I have to check if it is actually NSObject or NSProxy derivative instead of an Object derivative that does not support NSObject methods. This calls for runtime equivalent for one of the following NSObject methods: - [NSObject respondsToSelector:(SEL)aSelector] = class_respondsToSelector(Class, SEL) // this crashed. + [NSObject conformsToProtocol:(Protocol *)aProtocol] = class_conformsToProtocol(Class, Protocol *) // check for NSObject protocol, this does not work. + [NSObject isSubclassOfClass:(Class)aClass] // no equivalent, have to implement it myself I ended up creating this: BOOL class_isSubclassOfClass(Class cls, Class other) { for (Class c = cls; c; c = class_getSuperclass(c)) if (c == other) return YES; return NO; } If i remembered it right GNUstep runtime have this function. I will file a bug report to Apple and ask them to add this, as it is useful in class scanning and i am using this technique heavily in jailbreak detection. On Dec 14, 2014, at 01:20, Kyle Sluder k...@ksluder.com wrote: On Sat, Dec 13, 2014, at 10:19 AM, Phillip Mills wrote: Why do you think the problem is with “respondsToSelector:”? The error says you’re accessing past the end of a string. Because the crash happens in a call stack that originates in class_respondsToSelector, and involves none of Maxthon's code. --Kyle Sluder ___ 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/clarkcox3%40gmail.com This email sent to clarkc...@gmail.com smime.p7s Description: S/MIME cryptographic signature ___ 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: WTF is happening?
But I still need some way to tell them from NSObject/NSProxy decedents from my class walking. Any method calling will cause a crash there. On Dec 15, 2014, at 23:48, Clark S. Cox III clarkc...@gmail.com wrote: That does not mean that they're using Object only that they're using a base class other than NSObject or NSProxy. Why can't you just ignore such classes? Sent from my iPhone On Dec 14, 2014, at 23:31, Maxthon Chan m...@maxchan.info mailto:m...@maxchan.info wrote: My class scanning returned several OS* classes that does not conform to NSObject protocol. On Dec 15, 2014, at 00:29, Clark S. Cox III clarkc...@gmail.com mailto:clarkc...@gmail.com wrote: On Dec 13, 2014, at 11:57, Maxthon Chan m...@maxchan.info mailto:m...@maxchan.info wrote: NSProxy checking actually work, but throwing those classes that derive from Object class (note I used capitalised O here, the old Object class from early NeXT times, also used heavily in OS X kernel, GCD and Mach ports) What makes you think that Object is used in *any* of those places? into the mix means that no method can be sent before class is determined. I would suggest Apple add one runtime function class_isSubclassOfClass() that mirrors the functionality of NSObject and NSProxy method isSubclassOfClass so that derivatives of the old Object class can be detected more easily. On Dec 14, 2014, at 03:49, Gary L. Wade garyw...@desisoftsystems.com mailto:garyw...@desisoftsystems.com wrote: Are you saying that Apple's well-documented approach to see if an object is derived from NSProxy does not work? If that's the case, you need to submit a bug report to Apple. That's a serious issue that only Apple can help you with. If you are using objects not derived from NSObject nor NSProxy, then change your design. -- Gary L. Wade (Sent from my iPad) http://www.garywade.com/ http://www.garywade.com/ On Dec 13, 2014, at 11:40 AM, Maxthon Chan m...@maxchan.info mailto:m...@maxchan.info wrote: Ain’t work! Will crash if an Object derivative showed up. I am scanning ALL loaded classes and only subclasses of a certain class is interested. But due to the nature of this class scanning before I can make sure that the class derives from NSObject I cannot call any method on it. On Dec 14, 2014, at 03:34, Gary L. Wade garyw...@desisoftsystems.com mailto:garyw...@desisoftsystems.com wrote: If all you care about is if an object is a proxy or not, look at isProxy. -- Gary L. Wade (Sent from my iPad) http://www.garywade.com/ http://www.garywade.com/ On Dec 13, 2014, at 11:06 AM, Maxthon Chan m...@maxchan.info mailto:m...@maxchan.info wrote: What I am doing here is scanning all loaded classes for subclasses of a certain class. Before any NSObject method can be issued I have to check if it is actually NSObject or NSProxy derivative instead of an Object derivative that does not support NSObject methods. This calls for runtime equivalent for one of the following NSObject methods: - [NSObject respondsToSelector:(SEL)aSelector] = class_respondsToSelector(Class, SEL) // this crashed. + [NSObject conformsToProtocol:(Protocol *)aProtocol] = class_conformsToProtocol(Class, Protocol *) // check for NSObject protocol, this does not work. + [NSObject isSubclassOfClass:(Class)aClass] // no equivalent, have to implement it myself I ended up creating this: BOOL class_isSubclassOfClass(Class cls, Class other) { for (Class c = cls; c; c = class_getSuperclass(c)) if (c == other) return YES; return NO; } If i remembered it right GNUstep runtime have this function. I will file a bug report to Apple and ask them to add this, as it is useful in class scanning and i am using this technique heavily in jailbreak detection. On Dec 14, 2014, at 01:20, Kyle Sluder k...@ksluder.com mailto:k...@ksluder.com wrote: On Sat, Dec 13, 2014, at 10:19 AM, Phillip Mills wrote: Why do you think the problem is with “respondsToSelector:”? The error says you’re accessing past the end of a string. Because the crash happens in a call stack that originates in class_respondsToSelector, and involves none of Maxthon's code. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com mailto: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 http://lists.apple.com/ Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com https://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com This email sent to clarkc...@gmail.com mailto:clarkc...@gmail.com smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do
Re: WTF is happening?
bool isSubclass(Class cls, Class superclass) { if (class_respondsToSelector(object_getClass(cls), @selector(isSubclassOfClass:))) { return [cls isSubclassOfClass:superclass]; } } Le 15 déc. 2014 à 16:49, Maxthon Chan m...@maxchan.info a écrit : But I still need some way to tell them from NSObject/NSProxy decedents from my class walking. Any method calling will cause a crash there. On Dec 15, 2014, at 23:48, Clark S. Cox III clarkc...@gmail.com wrote: That does not mean that they're using Object only that they're using a base class other than NSObject or NSProxy. Why can't you just ignore such classes? Sent from my iPhone On Dec 14, 2014, at 23:31, Maxthon Chan m...@maxchan.info mailto:m...@maxchan.info wrote: My class scanning returned several OS* classes that does not conform to NSObject protocol. On Dec 15, 2014, at 00:29, Clark S. Cox III clarkc...@gmail.com mailto:clarkc...@gmail.com wrote: On Dec 13, 2014, at 11:57, Maxthon Chan m...@maxchan.info mailto:m...@maxchan.info wrote: NSProxy checking actually work, but throwing those classes that derive from Object class (note I used capitalised O here, the old Object class from early NeXT times, also used heavily in OS X kernel, GCD and Mach ports) What makes you think that Object is used in *any* of those places? into the mix means that no method can be sent before class is determined. I would suggest Apple add one runtime function class_isSubclassOfClass() that mirrors the functionality of NSObject and NSProxy method isSubclassOfClass so that derivatives of the old Object class can be detected more easily. On Dec 14, 2014, at 03:49, Gary L. Wade garyw...@desisoftsystems.com mailto:garyw...@desisoftsystems.com wrote: Are you saying that Apple's well-documented approach to see if an object is derived from NSProxy does not work? If that's the case, you need to submit a bug report to Apple. That's a serious issue that only Apple can help you with. If you are using objects not derived from NSObject nor NSProxy, then change your design. -- Gary L. Wade (Sent from my iPad) http://www.garywade.com/ http://www.garywade.com/ On Dec 13, 2014, at 11:40 AM, Maxthon Chan m...@maxchan.info mailto:m...@maxchan.info wrote: Ain’t work! Will crash if an Object derivative showed up. I am scanning ALL loaded classes and only subclasses of a certain class is interested. But due to the nature of this class scanning before I can make sure that the class derives from NSObject I cannot call any method on it. On Dec 14, 2014, at 03:34, Gary L. Wade garyw...@desisoftsystems.com mailto:garyw...@desisoftsystems.com wrote: If all you care about is if an object is a proxy or not, look at isProxy. -- Gary L. Wade (Sent from my iPad) http://www.garywade.com/ http://www.garywade.com/ On Dec 13, 2014, at 11:06 AM, Maxthon Chan m...@maxchan.info mailto:m...@maxchan.info wrote: What I am doing here is scanning all loaded classes for subclasses of a certain class. Before any NSObject method can be issued I have to check if it is actually NSObject or NSProxy derivative instead of an Object derivative that does not support NSObject methods. This calls for runtime equivalent for one of the following NSObject methods: - [NSObject respondsToSelector:(SEL)aSelector] = class_respondsToSelector(Class, SEL) // this crashed. + [NSObject conformsToProtocol:(Protocol *)aProtocol] = class_conformsToProtocol(Class, Protocol *) // check for NSObject protocol, this does not work. + [NSObject isSubclassOfClass:(Class)aClass] // no equivalent, have to implement it myself I ended up creating this: BOOL class_isSubclassOfClass(Class cls, Class other) { for (Class c = cls; c; c = class_getSuperclass(c)) if (c == other) return YES; return NO; } If i remembered it right GNUstep runtime have this function. I will file a bug report to Apple and ask them to add this, as it is useful in class scanning and i am using this technique heavily in jailbreak detection. On Dec 14, 2014, at 01:20, Kyle Sluder k...@ksluder.com mailto:k...@ksluder.com wrote: On Sat, Dec 13, 2014, at 10:19 AM, Phillip Mills wrote: Why do you think the problem is with “respondsToSelector:”? The error says you’re accessing past the end of a string. Because the crash happens in a call stack that originates in class_respondsToSelector, and involves none of Maxthon's code. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com mailto: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 http://lists.apple.com/ Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com
NSRegularExpression segfault
Hi! I recently needed to match some patterns but I encountered a problematic situation. Please, can anyone explain to me why does the following program consistently segfault after 5 characters? I'm running 10.9.5... #import Cocoa/Cocoa.h int main () { NSString *pattern = @(1+)|(2+)|(3+)|(4+)|(5+)|(6+)|(7+)|(8+)|(9+)|(0+)|(a+); NSRegularExpression *expression = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:nil]; for (NSUInteger i = 0; i 10; i += 1) { NSString *string = [@ stringByPaddingToLength:i withString:@a startingAtIndex:0]; NSTextCheckingResult *result = [expression firstMatchInString:string options:0 range:NSMakeRange(0, i)]; NSLog(@%@, NSStringFromRange([result range])); } return 0; } It says: {0, 0} {0, 1} {0, 2} {0, 3} {0, 4} {0, 5} Segmentation fault: 11 Thanks in advance! ___ 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: NSRegularExpression segfault
On Dec 15, 2014, at 8:38 AM, ecir hana ecir.h...@gmail.com wrote: Please, can anyone explain to me why does the following program consistently segfault after 5 characters? I'm running 10.9.5… What's the backtrace? Whenever investigating a crash you should always start by looking at the stack. (To get this in a text form you can paste into a message, use the debugger command bt.) My first guess was that you've hit one of those cases where certain regular expressions can take huge amounts of memory to match on long strings, but as you're running on OS X you've presumably got a 64-bit process, so that shouldn't be an issue. —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: NSRegularExpression segfault
On Mon, Dec 15, 2014 at 5:44 PM, Jens Alfke j...@mooseyard.com wrote: What's the backtrace? Whenever investigating a crash you should always start by looking at the stack. (To get this in a text form you can paste into a message, use the debugger command bt.) I don't seem to have bt but I got instead from Problem Report window: Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libicucore.A.dylib0x7fff8f301ac1 utext_clone + 22 1 libicucore.A.dylib0x7fff8f302570 icu::RegexMatcher::reset(UText*) + 54 2 libicucore.A.dylib0x7fff8f305f01 uregex_setText + 223 3 com.apple.Foundation 0x7fff8aba343f -[NSRegularExpression(NSMatching) enumerateMatchesInString:options:range:usingBlock:] + 938 4 com.apple.Foundation 0x7fff8ac13ba4 -[NSRegularExpression(NSMatching) firstMatchInString:options:range:] + 145 ___ 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: NSRegularExpression segfault
If you read the ICU docs on regular expressions you'll see that it sets an 8MB limit on head size when evaluating. My guess is that you've run into this and NSRegularExpression misses a return code somewhere. But your pattern is really suboptimal for what you're trying to accomplish. For example, this pattern is functionally equivalent and doesn't cause a crash for me: @(([0-9a])\\2*) That matches a single character, and then the same character 0 or more times. On Mon, Dec 15, 2014 at 10:38 AM, ecir hana ecir.h...@gmail.com wrote: Hi! I recently needed to match some patterns but I encountered a problematic situation. Please, can anyone explain to me why does the following program consistently segfault after 5 characters? I'm running 10.9.5... #import Cocoa/Cocoa.h int main () { NSString *pattern = @(1+)|(2+)|(3+)|(4+)|(5+)|(6+)|(7+)|(8+)|(9+)|(0+)|(a+); NSRegularExpression *expression = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:nil]; for (NSUInteger i = 0; i 10; i += 1) { NSString *string = [@ stringByPaddingToLength:i withString:@ a startingAtIndex:0]; NSTextCheckingResult *result = [expression firstMatchInString:string options:0 range:NSMakeRange(0, i)]; NSLog(@%@, NSStringFromRange([result range])); } return 0; } It says: {0, 0} {0, 1} {0, 2} {0, 3} {0, 4} {0, 5} Segmentation fault: 11 Thanks in advance! ___ 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/stephen.butler%40gmail.com This email sent to stephen.but...@gmail.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
Re: NSRegularExpression segfault
On Mon, Dec 15, 2014 at 6:09 PM, Stephen J. Butler stephen.but...@gmail.com wrote: If you read the ICU docs on regular expressions you'll see that it sets an 8MB limit on head size when evaluating. My guess is that you've run into this and NSRegularExpression misses a return code somewhere. I would have thought 50 000 characters is not that much. But then again, I don't really know how ICU works... Reading the ICU docs further, there it says: Because ICU does not use program recursion to maintain its backtracking state, stack usage during matching operations is minimal, and does not increase with complex patterns or large amounts of backtracking state. But your pattern is really suboptimal for what you're trying to accomplish. It's really a reduced test case. ___ 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: NSRegularExpression segfault
I ran into the same problem trying to write a parser of a markup language. I would suggest you to use some mechanism to break this long input to smaller chunks to match. Reggie is only good for lexical analysis which only deal with smaller chunks, bigger blocks need to be handled using grammatical analysis. On Dec 16, 2014, at 01:20, ecir hana ecir.h...@gmail.com wrote: On Mon, Dec 15, 2014 at 6:09 PM, Stephen J. Butler stephen.but...@gmail.com wrote: If you read the ICU docs on regular expressions you'll see that it sets an 8MB limit on head size when evaluating. My guess is that you've run into this and NSRegularExpression misses a return code somewhere. I would have thought 50 000 characters is not that much. But then again, I don't really know how ICU works... Reading the ICU docs further, there it says: Because ICU does not use program recursion to maintain its backtracking state, stack usage during matching operations is minimal, and does not increase with complex patterns or large amounts of backtracking state. But your pattern is really suboptimal for what you're trying to accomplish. It's really a reduced test case. ___ 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/max%40maxchan.info This email sent to m...@maxchan.info smime.p7s Description: S/MIME cryptographic signature ___ 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: WTF is happening?
On Dec 13, 2014, at 7:20 AM, Maxthon Chan m...@maxchan.info wrote: This got me scratching my head, hard. Why would class_respondsToSelector() crash? (BTW this is used in a class search loop so I cannot use [NSObject respondsToSelector:] just yet.) /Users/technix/Developer/Subtitler Pro/Frameworks/SubtitleKit/SubtitleKitTests/SKSubripParseTest.m:33: error: -[SKSubripParseTest testFileFormatSearch] : failed: caught NSRangeException, *** -[__NSCFString substringFromIndex:]: Index 18 out of bounds; string length 17 ( 0 CoreFoundation 0x7fff926c __exceptionPreprocess + 172 1 libobjc.A.dylib 0x7fff8725976e objc_exception_throw + 43 2 CoreFoundation 0x7fff9266651d +[NSException raise:format:] + 205 3 Foundation 0x7fff8f127b2e -[NSString substringFromIndex:] + 118 4 AppKit 0x7fff8a4e1c49 +[_NSObjectAnimator _targetClass] + 92 5 AppKit 0x7fff8a4e1b79 +[_NSObjectAnimator resolveInstanceMethod:] + 34 6 libobjc.A.dylib 0x7fff8725c954 _ZL28_class_resolveInstanceMethodP10objc_classP13objc_selectorP11objc_object + 80 From this call stack it looks like you are tripping over an internal implementation detail of AppKit in a way that is not expected. In particular, +[_NSObjectAnimator _targetClass] (an internal class) is calling -[NSString substringFromIndex:] and passing an invalid index, probably due to some implementation detail that your code is violating. Given you are inside +resolveInstanceMethod:, my guess would be that by trying to dynamically look up the instance method, you are tripping over code that determines where to get that instance method from that doesn’t expect to be called on the raw _NSObjectAnimator. My minimal recommendation would be to filter out all classes that begin with an “_” prefix from your scan. But I would be curious as to why you need to know the subclass information up front and not just as you encounter particular classes (granted this is for a test it seems, but it seems like it would be prudent to reduce your test to a more reasonable scope). 7 libobjc.A.dylib 0x7fff87262799 lookUpImpOrForward + 356 8 libobjc.A.dylib 0x7fff87262617 lookUpImpOrNil + 20 9 libobjc.A.dylib 0x7fff872545ff class_respondsToSelector + 37 10 SubtitleKit 0x0001000d02c8 +[SKFormat formatEngineForExtension:] + 184 11 SubtitleKitTests0x00010008551e -[SKSubripParseTest testFileFormatSearch] + 142 12 CoreFoundation 0x7fff9253f3cc __invoking___ + 140 13 CoreFoundation 0x7fff9253f222 -[NSInvocation invoke] + 290 14 XCTest 0x000100097919 -[XCTestCase invokeTest] + 253 15 XCTest 0x000100097b1a -[XCTestCase performTest:] + 150 16 XCTest 0x0001000a0700 -[XCTest run] + 257 17 XCTest 0x00010009682b -[XCTestSuite performTest:] + 379 18 XCTest 0x0001000a0700 -[XCTest run] + 257 19 XCTest 0x00010009682b -[XCTestSuite performTest:] + 379 20 XCTest 0x0001000a0700 -[XCTest run] + 257 21 XCTest 0x00010009682b -[XCTestSuite performTest:] + 379 22 XCTest 0x0001000a0700 -[XCTest run] + 257 23 XCTest 0x00010009383c __25-[XCTestDriver _runSuite]_block_invoke + 56 24 XCTest 0x00010009f36d -[XCTestObservationCenter _observeTestExecutionForBlock:] + 162 25 XCTest 0x000100093770 -[XCTestDriver _runSuite] + 269 26 XCTest 0x000100094359 -[XCTestDriver _checkForTestManager] + 678 27 XCTest 0x0001000a35b0 +[XCTestProbe runTests:] + 182 28 xctest 0x00011256 xctest + 4694 29 xctest 0x000115d6 xctest + 5590 30 xctest 0x00010ed3 xctest + 3795 31 libdyld.dylib 0x7fff90e315c9 start + 1 ) ___ 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
Re: NSRegularExpression segfault
It seems to be related to the number of capture groups you have. For example, this also succeeds for me: ((?:1+)|(?:2+)|(?:3+)|(?:4+)|(?:5+)|(?:6+)|(?:7+)|(?:8+)|(?:9+)|(?:0+)|(?:a+)) Do you really need the 11 capture groups? On Mon, Dec 15, 2014 at 11:20 AM, ecir hana ecir.h...@gmail.com wrote: On Mon, Dec 15, 2014 at 6:09 PM, Stephen J. Butler stephen.but...@gmail.com wrote: If you read the ICU docs on regular expressions you'll see that it sets an 8MB limit on head size when evaluating. My guess is that you've run into this and NSRegularExpression misses a return code somewhere. I would have thought 50 000 characters is not that much. But then again, I don't really know how ICU works... Reading the ICU docs further, there it says: Because ICU does not use program recursion to maintain its backtracking state, stack usage during matching operations is minimal, and does not increase with complex patterns or large amounts of backtracking state. But your pattern is really suboptimal for what you're trying to accomplish. It's really a reduced test case. ___ 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: WTF is happening?
What I am doing here is to determine a format handling class based on file extension. I want to achieve a drop-to-plugin-folder-and-it-will-work effect and allow one plugin to include multiple format handling classes. Also since I am creating an open system I don’t want to require other plugin writers to register their classes, instead the main code shall discover plugins on its own. This means that the main code will not be able to call any plugin classes methods so +initialize never get called. Also your approach means that the main code will hold a strong reference to the plugin code which prevents plugin unloading. Class walking may be fragile, but it is fragile enough to allow plugins to come and go easily without having to restart the main code. On Dec 15, 2014, at 20:42, Jean-Daniel Dupas mail...@xenonium.com wrote: Le 15 déc. 2014 à 13:31, Uli Kusterer witness.of.teacht...@gmx.net a écrit : On 15 Dec 2014, at 12:42, Jean-Daniel Dupas mail...@xenonium.com wrote: I found only 5 classes that does not responds to isProxy and they are all internal classes, so real code will never have to deal with instances of such classes. Maxthon is iterating over the classes in the system. Even internal classes to the OS show up in that list, so I really don't see how he would *not* have to be able to at least deal with their presence. Fair enough, but I didn’t got any issue while dealing with theses classes. I managed to query if they responds to a selector, got there superclass and more. Apart from completely re-thinking his approach. E.g. NSImageRep, AFAIK, simply has each image representation subclass add itself to an NSArray from its +initialize method. I'd think that'd be less fragile than walking the entire class list. I fully agree on that. Relying on class iteration is generally a design flaw. It is too fragile to be used in a reliable and futur proof way. But I don’t think you can rely on +initialize to register subclasses as initialize will not be called until the someone try to use the target class (or one of it’s subclass). You can use +load but should probably be careful when doing so as there is no guarantee about the class loading order AFAIK. ___ 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/max%40maxchan.info This email sent to m...@maxchan.info smime.p7s Description: S/MIME cryptographic signature ___ 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: NSRegularExpression segfault
On Mon, Dec 15, 2014 at 6:50 PM, Stephen J. Butler stephen.but...@gmail.com wrote: It seems to be related to the number of capture groups you have. For example, this also succeeds for me: ((?:1+)|(?:2+)|(?:3+)|(?:4+)|(?:5+)|(?:6+)|(?:7+)|(?:8+)|(?:9+)|(?:0+)|(?:a+)) Do you really need the 11 capture groups? Thanks for giving it a try! It's not precisely 11, but yes, I need to have many. I also discovered it is related to the number of capture groups and their complexity. One single group works for much longer inputs but I guess you already know that. To put it differently, even if I could reduce the number of groups a bit, I think I will still hit that segfault for some non-trivial inputs. For example, when I only use 6 groups it still segfaults at around 80 000 characters. ___ 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: NSRegularExpression segfault
On Mon, Dec 15, 2014 at 6:59 PM, ecir hana ecir.h...@gmail.com wrote: It's not precisely 11, but yes, I need to have many. By many I mean more than 2 and less than...maybe 10. ___ 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: Apple Events not being handled during UI tracking
does anyone have any idea why this is happening now? how to fix it properly? On Dec 14, 2014, at 12:27 PM, David M. Cotter m...@davecotter.com wrote: In Mavericks and earlier, AppleEvents would dispatch as they came in, even during control-tracking (eg: the menu bar) however, in Yosemite, AEs are blocked. what’s the deal there? anyone know why? a workaround is to install an idle timer and manually pull events, but that’s so 90’s. shouldn’t they just continue to handle themselves?? ___ 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: WTF is happening?
On Dec 15, 2014, at 9:59 AM, Maxthon Chan m...@maxchan.info wrote: I do own the entire SubtitleKit framework but the problem is I want it allow loading and unloading format plugins without restarting the host application. This library only have one internal parser for basic SubRip format and plugins are used for styled SubRip, Multi-track SubRip, SubStation Alpha and other formats. You can post a notification when a format plugin loads (aka registers itself) for those that are interested in knowing that new formats are available. As for unloading, unloading Objective-C code is generally considered difficult at best, especially since it is often hard to control whom is referencing any content in the binary (and where once you’ve unloaded that bundle anyone referencing that code will crash). Overall the simplest solution seems to be that your SubtitleKit framework provides a method for loading these format plugins and does the registration itself. Your users always use that method and you don’t have any of these problems. -- David Duncan ___ 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: WTF is happening?
My current design is that the main code is never possible of holding strong references to plugin code for extended periods. Main code keeps an eye on a folder and whenever a new bundle is dropped in it is loaded, and whenever a bundle is removed code is unloaded. Class walking is used to detect the classes loaded. Also, SKFormat does not have any instance methods, only class methods, just to prevent any autorelease pool holding onto it. On Dec 16, 2014, at 02:09, David Duncan david.dun...@apple.com wrote: On Dec 15, 2014, at 9:59 AM, Maxthon Chan m...@maxchan.info mailto:m...@maxchan.info wrote: I do own the entire SubtitleKit framework but the problem is I want it allow loading and unloading format plugins without restarting the host application. This library only have one internal parser for basic SubRip format and plugins are used for styled SubRip, Multi-track SubRip, SubStation Alpha and other formats. You can post a notification when a format plugin loads (aka registers itself) for those that are interested in knowing that new formats are available. As for unloading, unloading Objective-C code is generally considered difficult at best, especially since it is often hard to control whom is referencing any content in the binary (and where once you’ve unloaded that bundle anyone referencing that code will crash). Overall the simplest solution seems to be that your SubtitleKit framework provides a method for loading these format plugins and does the registration itself. Your users always use that method and you don’t have any of these problems. -- David Duncan smime.p7s Description: S/MIME cryptographic signature ___ 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: WTF is happening?
And if you have a constant NSString in the binary, and that string is referenced anywhere in the application, then unloading the binary will crash the next time that constant string is referenced. It is *really* hard to make a properly un-loadable bundle and generally in-advised, as the advantages tend to be non-existant compared to the effort required. And also, if you are loading the bundle, then again there is little need to do actual class walking as such, since you are in control of the bundle and its formatting. Require the bundles to tell you the classes that are SKFormat subclasses in the bundle’s property list and only use those. On Dec 15, 2014, at 10:19 AM, Maxthon Chan m...@maxchan.info wrote: My current design is that the main code is never possible of holding strong references to plugin code for extended periods. Main code keeps an eye on a folder and whenever a new bundle is dropped in it is loaded, and whenever a bundle is removed code is unloaded. Class walking is used to detect the classes loaded. Also, SKFormat does not have any instance methods, only class methods, just to prevent any autorelease pool holding onto it. On Dec 16, 2014, at 02:09, David Duncan david.dun...@apple.com mailto:david.dun...@apple.com wrote: On Dec 15, 2014, at 9:59 AM, Maxthon Chan m...@maxchan.info mailto:m...@maxchan.info wrote: I do own the entire SubtitleKit framework but the problem is I want it allow loading and unloading format plugins without restarting the host application. This library only have one internal parser for basic SubRip format and plugins are used for styled SubRip, Multi-track SubRip, SubStation Alpha and other formats. You can post a notification when a format plugin loads (aka registers itself) for those that are interested in knowing that new formats are available. As for unloading, unloading Objective-C code is generally considered difficult at best, especially since it is often hard to control whom is referencing any content in the binary (and where once you’ve unloaded that bundle anyone referencing that code will crash). Overall the simplest solution seems to be that your SubtitleKit framework provides a method for loading these format plugins and does the registration itself. Your users always use that method and you don’t have any of these problems. -- David Duncan -- David Duncan ___ 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: WTF is happening?
I can be dense. Do I understand correctly that - You have an application that ideally should run continually. - It accepts plugins that provide one or more classes. - Those classes must at least observe a protocol; otherwise there would be no sensible way to use them. - They must have unique names. - As is typical of ObjC plugins, the classes are packaged in a dynamic library; and as is typical, the library is wrapped in a package directory, which your application has registered with Launch Services as a package, of a certain type and edit/view/associate relationship to your application. I'm sure this is so in your case, as plugins typically need to carry resource files. - If a package, the plugin might carry an Info.plist file — plugins commonly do. - You mean to load and unload plugins dynamically, as they appear and disappear in a designated directory, without interrupting the application. Do I follow you so far? If so, I have some comments. You can't unscramble the egg: Dynamically-loaded classes can be loaded any time you like, but they cannot be reloaded or unloaded. Surely you know this; surely I misunderstand (or am behind the times). If you are (practically) committed to a package structure with an Info.plist, why can't you add an array key listing the names of the provided classes? Or for that matter, a text file containing the names? That's one of the things NSBundle is for. It is a universal practice. Just works is a great ideal, but one can expect someone who knows how to build a dynamic library to understand such things. The declared classes might not implement the required methods, but that's easy and safe to detect once they are loaded. If you must reject, your duty ends when you log the problem and put up an alert. Am I missing something? — F On Dec 15, 2014, at 11:59 AM, Maxthon Chan m...@maxchan.info wrote: What I am doing here is to determine a format handling class based on file extension. I want to achieve a drop-to-plugin-folder-and-it-will-work effect and allow one plugin to include multiple format handling classes. Also since I am creating an open system I don’t want to require other plugin writers to register their classes, instead the main code shall discover plugins on its own. This means that the main code will not be able to call any plugin classes methods so +initialize never get called. Also your approach means that the main code will hold a strong reference to the plugin code which prevents plugin unloading. Class walking may be fragile, but it is fragile enough to allow plugins to come and go easily without having to restart the main code. ___ 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: WTF is happening?
Le 15 déc. 2014 à 19:45, Fritz Anderson fri...@manoverboard.org a écrit : I can be dense. Do I understand correctly that - You have an application that ideally should run continually. - It accepts plugins that provide one or more classes. - Those classes must at least observe a protocol; otherwise there would be no sensible way to use them. - They must have unique names. - As is typical of ObjC plugins, the classes are packaged in a dynamic library; and as is typical, the library is wrapped in a package directory, which your application has registered with Launch Services as a package, of a certain type and edit/view/associate relationship to your application. I'm sure this is so in your case, as plugins typically need to carry resource files. Just for the record, typical Obj-C plugins are packaged in loadable bundle (MH_BUNDLE), which are a different binary object kind than dynamic library (MH_DYLIB). - If a package, the plugin might carry an Info.plist file — plugins commonly do. - You mean to load and unload plugins dynamically, as they appear and disappear in a designated directory, without interrupting the application. Do I follow you so far? If so, I have some comments. You can't unscramble the egg: Dynamically-loaded classes can be loaded any time you like, but they cannot be reloaded or unloaded. Surely you know this; surely I misunderstand (or am behind the times). If you are (practically) committed to a package structure with an Info.plist, why can't you add an array key listing the names of the provided classes? Or for that matter, a text file containing the names? That's one of the things NSBundle is for. It is a universal practice. Just works is a great ideal, but one can expect someone who knows how to build a dynamic library to understand such things. The declared classes might not implement the required methods, but that's easy and safe to detect once they are loaded. If you must reject, your duty ends when you log the problem and put up an alert. Am I missing something? — F On Dec 15, 2014, at 11:59 AM, Maxthon Chan m...@maxchan.info wrote: What I am doing here is to determine a format handling class based on file extension. I want to achieve a drop-to-plugin-folder-and-it-will-work effect and allow one plugin to include multiple format handling classes. Also since I am creating an open system I don’t want to require other plugin writers to register their classes, instead the main code shall discover plugins on its own. This means that the main code will not be able to call any plugin classes methods so +initialize never get called. Also your approach means that the main code will hold a strong reference to the plugin code which prevents plugin unloading. Class walking may be fragile, but it is fragile enough to allow plugins to come and go easily without having to restart the main code. ___ 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: NSRegularExpression segfault
On Dec 15, 2014, at 8:56 AM, ecir hana ecir.h...@gmail.com wrote: I don't seem to have bt but I got instead from Problem Report window: Sounds like you're not running the app in Xcode. If you're hitting a crash or other bug you should always try to reproduce it while running the app in Xcode, so the debugger can kick in. Anyway, please file a bug report with Apple, as this seems to be a bug in NSRegularExpression. I would have thought 50 000 characters is not that much. But then again, I don't really know how ICU works... Reading the ICU docs further, there it says: Because ICU does not use program recursion to maintain its backtracking state, stack usage during matching operations is minimal, and does not increase with complex patterns or large amounts of backtracking state. It's not blowing up the stack. But it has to store backtracking state _somewhere_, and apparently it has a fixed-size buffer for this, which overflows while handling your regex because it's run into some pathological condition. Then, presumably, NSRegularExpression isn't noticing the error and ends up crashing by trying to operate on the nonexistent output. I'm no expert on regular expressions, but my understanding is that all the implementations have a couple of pathological conditions where for certain expressions the memory usage goes up rapidly with input length, and if you run into one of those you'll need to adjust your expression to work around it. —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: WTF is happening?
On Dec 15, 2014, at 11:02 AM, Jean-Daniel Dupas mail...@xenonium.com wrote: Le 15 déc. 2014 à 19:45, Fritz Anderson fri...@manoverboard.org a écrit : - As is typical of ObjC plugins, the classes are packaged in a dynamic library; and as is typical, the library is wrapped in a package directory, which your application has registered with Launch Services as a package, of a certain type and edit/view/associate relationship to your application. I'm sure this is so in your case, as plugins typically need to carry resource files. Just for the record, typical Obj-C plugins are packaged in loadable bundle (MH_BUNDLE), which are a different binary object kind than dynamic library (MH_DYLIB). MH_BUNDLE is no longer typical. The only advantage of MH_BUNDLE is that you might be able to unload it, but you probably shouldn't try. Feel free to use MH_DYLIB for all of your plugin needs. (libobjc prevents unloading of any MH_DYLIB containing Objective-C metadata. It does not summarily disallow unloading of MH_BUNDLE, but there's a long list of caveats that make bundle unloading unusable except in rare situations.) -- Greg Parker gpar...@apple.com Runtime Wrangler ___ 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: WTF is happening?
On Dec 13, 2014, at 7:20 AM, Maxthon Chan m...@maxchan.info wrote: This got me scratching my head, hard. Why would class_respondsToSelector() crash? (BTW this is used in a class search loop so I cannot use [NSObject respondsToSelector:] just yet.) Your evil runtime hack is colliding with someone else's evil runtime hack. If a class does not have an implementation for some selector then the runtime asks the class if it would like to add one using +resolveInstanceMethod: or +resolveClassMethod:. In this case you have found that the implementation of +[_NSObjectAnimator resolveInstanceMethod:] crashes. (It turns out that _NSObjectAnimator assumes the message is only sent to its subclasses, not to _NSObjectAnimator itself.) In general it is not safe to look up arbitrary classes and then send messages to them. Checking for conformance (using the C function, not the NSObject method) to a protocol you defined and then only sending messages from that protocol is the safest way to go. Filtering out classes with base classes that are not NSObject sometimes works. Filtering out classes whose names start with _ sometimes works. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ 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: NSRegularExpression segfault
On Mon, Dec 15, 2014 at 8:04 PM, Jens Alfke j...@mooseyard.com wrote: Anyway, please file a bug report with Apple, as this seems to be a bug in NSRegularExpression. Done! I'm no expert on regular expressions, but my understanding is that all the implementations have a couple of pathological conditions where for certain expressions the memory usage goes up rapidly with input length, and if you run into one of those you'll need to adjust your expression to work around it. I'm also no expert on regexps but I thought that the pathological conditions are met when using back-references (which I don't use). In any case, I tried it in JavaScript and it works up to 10 000 000 characters (I didn't try more). var pattern = /(1+)|(2+)|(3+)|(4+)|(5+)|(6+)|(7+)|(8+)|(9+)|(0+)|(a+)/; var result = pattern.exec(new Array(1001).join(a)); console.log(result.index, result[0].length); Thanks again for all the replies! ___ 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: WTF is happening?
Le 15 déc. 2014 à 21:36, Greg Parker gpar...@apple.com a écrit : On Dec 15, 2014, at 11:02 AM, Jean-Daniel Dupas mail...@xenonium.com wrote: Le 15 déc. 2014 à 19:45, Fritz Anderson fri...@manoverboard.org a écrit : - As is typical of ObjC plugins, the classes are packaged in a dynamic library; and as is typical, the library is wrapped in a package directory, which your application has registered with Launch Services as a package, of a certain type and edit/view/associate relationship to your application. I'm sure this is so in your case, as plugins typically need to carry resource files. Just for the record, typical Obj-C plugins are packaged in loadable bundle (MH_BUNDLE), which are a different binary object kind than dynamic library (MH_DYLIB). MH_BUNDLE is no longer typical. The only advantage of MH_BUNDLE is that you might be able to unload it, but you probably shouldn't try. Feel free to use MH_DYLIB for all of your plugin needs. It is typical in the sense that Xcode defaults to mach-o type bundle when creating a plugin project and most (if not all) Apple provided plugins are bundle (as are most third party plugins). (libobjc prevents unloading of any MH_DYLIB containing Objective-C metadata. It does not summarily disallow unloading of MH_BUNDLE, but there's a long list of caveats that make bundle unloading unusable except in rare situations.) ___ 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
PList Data Typing
Hi All, I'm needing to read in a PList, that others have designed, I have no control over the input. One of the Keys stores either a String, Number or Boolean value. Checking for the NSString is straight forward. How can I tell if the Value is a Boolean or Number in the NSDictionary? as 0 and 1 are valid values for a number. cheers Kevin ___ 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: WTF is happening?
On Dec 13, 2014, at 11:06 AM, Maxthon Chan m...@maxchan.info wrote: What I am doing here is scanning all loaded classes for subclasses of a certain class. Before any NSObject method can be issued I have to check if it is actually NSObject or NSProxy derivative instead of an Object derivative that does not support NSObject methods. This calls for runtime equivalent for one of the following NSObject methods: For what it’s worth we’ve run into this same problem at Omni— we have some code (that runs in debug builds, but not release builds, IIRC) that scans the class hierarchy. We simply ignore a bunch of classes that we’ve had problems with. This works, but it’s a little bit brittle because who knows when another class will appear in the runtime that can’t handle -respondsToSelector: and break your shipping application. /* Some classes (that aren't our problem) asplode when they try to dynamically create getters/setters. */ const char *clsName = class_getName(cls); if (CLASSNAME_HAS_PREFIX(clsName, NS) || CLASSNAME_HAS_PREFIX(clsName, _NS) || CLASSNAME_HAS_PREFIX(clsName, __NS) || CLASSNAME_HAS_PREFIX(clsName, __CF) || CLASSNAME_HAS_PREFIX(clsName, CA) || CLASSNAME_HAS_PREFIX(clsName, _CN) || CLASSNAME_HAS_PREFIX(clsName, VGL) || CLASSNAME_HAS_PREFIX(clsName, VK) || strcmp(clsName, DRDevice) == 0) { /* In particular, _NS[View]Animator chokes in this case. But we don't really need to check any _NS classes. */ continue; } On Dec 15, 2014, at 10:23 AM, David Duncan david.dun...@apple.com wrote: And also, if you are loading the bundle, then again there is little need to do actual class walking as such, since you are in control of the bundle and its formatting. Require the bundles to tell you the classes that are SKFormat subclasses in the bundle’s property list and only use those. IMHO this is the best approach to the problem. Another approach is you could watch for the NSBundleDidLoadNotification and only scan the classes in the NSLoadedClasses entry. But I think that requiring the plugin to explicitly list the classes you should scan in its Info.plist is a good approach. ___ 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: PList Data Typing
On Dec 15, 2014, at 2:10 PM, Kevin Bracey ke...@ilike.co.nz wrote: How can I tell if the Value is a Boolean or Number in the NSDictionary? as 0 and 1 are valid values for a number. There's no clean solution for this. You have to take advantage of the fact that the YES and NO NSNumbers are singleton objects, and do a direct pointer comparison (with ==, *not* with isEqual:) — if (obj == @YES) { it's YES } else if (obj == @NO) { it's NO } else { it's a number (possibly 0 or 1) } —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: PList Data Typing
Thanks Jens, You’re fantastic! Have a great holiday season to all, and thanks for all the help over the years! On 16/12/2014, at 11:28 am, Jens Alfke j...@mooseyard.com wrote: On Dec 15, 2014, at 2:10 PM, Kevin Bracey ke...@ilike.co.nz wrote: How can I tell if the Value is a Boolean or Number in the NSDictionary? as 0 and 1 are valid values for a number. There's no clean solution for this. You have to take advantage of the fact that the YES and NO NSNumbers are singleton objects, and do a direct pointer comparison (with ==, *not* with isEqual:) — if (obj == @YES) { it's YES } else if (obj == @NO) { it's NO } else { it's a number (possibly 0 or 1) } —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: PList Data Typing
On Dec 15, 2014, at 4:10 PM, Kevin Bracey ke...@ilike.co.nz wrote: I'm needing to read in a PList, that others have designed, I have no control over the input. One of the Keys stores either a String, Number or Boolean value. Checking for the NSString is straight forward. How can I tell if the Value is a Boolean or Number in the NSDictionary? as 0 and 1 are valid values for a number. In Cocoa, both booleans and numbers are represented by NSNumber. In Core Foundation, there are distinct types, CFBoolean and CFNumber. NSNumber and CFNumber are toll-free bridged, but there's no similar guarantee about NSNumber and CFBoolean. The most reliable solution may be to use Core Foundation to deserialize the property list. See CFPropertyList https://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFPropertyListRef/index.html. For any given object in the resulting property list, you can check its type using the standard mechanism for CFTypes. Call CFGetTypeID() on the object and then compare the result to CFBooleanGetTypeID(), CFNumberGetTypeID(), etc. 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
Re: Using AV Foundation to record m3u8 stream to disk
I'm not certain if this is useful to you but Bob McCune on Twitter mentioned a new tech note about new avfoundation apis which specifically mentions reference movies. https://developer.apple.com/library/mac/technotes/tn2404/_index.html#//apple_ref/doc/uid/DTS40015060 I'd also recommend his book learning avfoundation. Kevin Sent from my iPad On 15 Dec 2014, at 02:57, Graham Cox graham@bigpond.com wrote: Just an update on this, since I've made some useful progress, but I'm a bit stuck again. I am able to download the video streams and write them to a .ts file which plays fine in apps such as VLC (Quicktime Player not so much). So far this is all done with NSURLSession, breaking apart the m3u8 file(s) and loading each media chunk, reassembling them into the correct order and writing them to the file. What I'd like to do now is to have a live preview of what data is being received (so far I just accumulate it to the file with no preview). AVPlayer can do this all by itself, but I assume that it's going to be duplicating the download, thus doubling the bandwidth I need. What I'd rather do is feed my already downloaded chunks of data to an AVPlayer somehow. This is where the AV Foundation programming guide and the framework itself is a bit daunting - I don't really know which objects I need to be looking at. I'm thinking AVCaptureInput... or is it AVCaptureInputPort, or maybe AVAssetReader. Unfortunately this sort of low level extension of AV Foundation isn't well covered in the programming guide. Some useful pointers to the rough shape of what I need to do would get my project moving again. --Graham On 9 Dec 2014, at 10:37 am, Graham Cox graham@bigpond.com wrote: OK, thanks. I was hoping that I didn't need to delve into the internals of the m3u8 format itself, since AVPlayer/AVPlayerView handles it just fine - I just make a NSURL from the m3u8 url and away it goes. By the way, it isn't just audio, it's video and audio and possibly other things - there are three tracks in the asset for the stream I tested with but I forget what the third is now (first two were video and audio). It seems as if the architecture of AV Foundation allows what I want, but the actual implementation doesn't, *unless I've missed something*. I'm wondering if this gap in the implementation is deliberate for some reason, is there but requires some other combinaiton of parameters from the nes I've tried, on Apple's 'to do' list or is fundamentally not possible. --Graham On 9 Dec 2014, at 4:50 am, dangerwillrobinsondan...@gmail.com wrote: Sent from my iPhone On 2014/12/09, at 1:38, Jens Alfke j...@mooseyard.com wrote: m3u8 isn't a stream, it's simply a small playlist file that contains one or more HTTP URLs, which resolve to audio files, usually MP3. In the case of streaming, the HTTP audio resource uses the Shoutcast format, which is basically just an audio stream that looks like an infinitely long MP3 file. So all you need to do is read the URL from the .m3u8 file (which is pretty trivial; IIRC it's just a text file containing a URL) and use something like NSURLConnection to read data from it and write it to a file with a .mp3 extension. Since it's a stream you'll never hit EOF so you'll want to stop the connection after a while. If you need to write the audio into some other kind of movie file you should be able to feed the data received from the URL into AVFoundation. You'll just need to inform it that the data format is MP3. It is not limited to MP3 Http Live Streaming uses this playlist format. Literally just a list of URLs really. Where each one is a short clip of media content. The content on the other end is usually small files as parts of the whole. The u on the end means UTF8. The video format could vary. ___ 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/graham.cox%40bigpond.com This email sent to graham@bigpond.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/ktam%40yvs.eu.com This email sent to k...@yvs.eu.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:
Re: Using AV Foundation to record m3u8 stream to disk
I actually just chanced across his book last night while trying to dig through AVAudioEngine. Bought it. Good book so far. Paints a good picture of the overall AV Foundation landscape today. Sent from my iPhone On 2014/12/16, at 7:59, Kevin Meaney k...@yvs.eu.com wrote: I'm not certain if this is useful to you but Bob McCune on Twitter mentioned a new tech note about new avfoundation apis which specifically mentions reference movies. https://developer.apple.com/library/mac/technotes/tn2404/_index.html#//apple_ref/doc/uid/DTS40015060 I'd also recommend his book learning avfoundation. Kevin Sent from my iPad ___ 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: WTF is happening?
I ended up written my own runtime-level equivalent of +[NSObject isSubclassOfClass:] using only class_getSuperclass and object_getClass. This class scanning code, currently used for plugin scanning, will also be used in jailbreak detecting, defeating Cydia Substrate-based iAP crackers. On Dec 16, 2014, at 06:25, Wim Lewis w...@omnigroup.com wrote: On Dec 13, 2014, at 11:06 AM, Maxthon Chan m...@maxchan.info wrote: What I am doing here is scanning all loaded classes for subclasses of a certain class. Before any NSObject method can be issued I have to check if it is actually NSObject or NSProxy derivative instead of an Object derivative that does not support NSObject methods. This calls for runtime equivalent for one of the following NSObject methods: For what it’s worth we’ve run into this same problem at Omni— we have some code (that runs in debug builds, but not release builds, IIRC) that scans the class hierarchy. We simply ignore a bunch of classes that we’ve had problems with. This works, but it’s a little bit brittle because who knows when another class will appear in the runtime that can’t handle -respondsToSelector: and break your shipping application. /* Some classes (that aren't our problem) asplode when they try to dynamically create getters/setters. */ const char *clsName = class_getName(cls); if (CLASSNAME_HAS_PREFIX(clsName, NS) || CLASSNAME_HAS_PREFIX(clsName, _NS) || CLASSNAME_HAS_PREFIX(clsName, __NS) || CLASSNAME_HAS_PREFIX(clsName, __CF) || CLASSNAME_HAS_PREFIX(clsName, CA) || CLASSNAME_HAS_PREFIX(clsName, _CN) || CLASSNAME_HAS_PREFIX(clsName, VGL) || CLASSNAME_HAS_PREFIX(clsName, VK) || strcmp(clsName, DRDevice) == 0) { /* In particular, _NS[View]Animator chokes in this case. But we don't really need to check any _NS classes. */ continue; } On Dec 15, 2014, at 10:23 AM, David Duncan david.dun...@apple.com wrote: And also, if you are loading the bundle, then again there is little need to do actual class walking as such, since you are in control of the bundle and its formatting. Require the bundles to tell you the classes that are SKFormat subclasses in the bundle’s property list and only use those. IMHO this is the best approach to the problem. Another approach is you could watch for the NSBundleDidLoadNotification and only scan the classes in the NSLoadedClasses entry. But I think that requiring the plugin to explicitly list the classes you should scan in its Info.plist is a good approach. ___ 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/max%40maxchan.info This email sent to m...@maxchan.info smime.p7s Description: S/MIME cryptographic signature ___ 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: WTF is happening?
In this case you have found that the implementation of +[_NSObjectAnimator resolveInstanceMethod:] crashes. IMHO, this is a nasty little bug… and a simple test case should be added to the frameworks to check that basic runtime functionality works on all classes - private or publicly declared. Even if nothing else is guaranteed, if a thing says it’s a class, then it really kinda’ should act like one. In general it is not safe to look up arbitrary classes and then send messages to them. True. However, he called a C runtime function… it happens that that function invokes the forwarding mechanism, but it’s still a basic runtime C function, below the level of the NSObject abstractions… so it really *should* work... Checking for conformance (using the C function, not the NSObject method) to a protocol you defined and then only sending messages from that protocol is the safest way to go. I would (and in my own code, do) combine that with the suggestions to interrogate the bundle being loaded for classes to be examined, as well as do registration of classes in +load… I also post some notifications of my own at various key points in my app startup cycle that various interested classes can hook to. On Dec 15, 2014, at 3:36 PM, Maxthon Chan m...@maxchan.info wrote: I ended up written my own runtime-level equivalent of +[NSObject isSubclassOfClass:] using only class_getSuperclass and object_getClass. This class scanning code, currently used for plugin scanning, will also be used in jailbreak detecting, defeating Cydia Substrate-based iAP crackers. You need to be very careful of how you implement that so that a future OS update doesn’t break your app… ___ 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