adium 2303:e8ab3917209a: AIStringDebug should probably modify st...

commits at adium.im commits at adium.im
Sun May 24 08:08:08 UTC 2009


details:	http://hg.adium.im/adium/rev/e8ab3917209a
revision:	2303:e8ab3917209a
author:		David Smith <catfish.man at gmail.com>
date:		Sun May 24 01:05:50 2009 -0700

AIStringDebug should probably modify strings... copy-paste error I think
Subject: adium 2304:4fff1c47e9f2: Sending an object a selector it doesn't recognize currently breaks Adium in mysterious and unpredictable ways by unwinding the stack out from under code that doesn't expect it. Instead, let's just crash so we can get a stack trace and fix it.

details:	http://hg.adium.im/adium/rev/4fff1c47e9f2
revision:	2304:4fff1c47e9f2
author:		David Smith <catfish.man at gmail.com>
date:		Sun May 24 01:06:52 2009 -0700

Sending an object a selector it doesn't recognize currently breaks Adium in mysterious and unpredictable ways by unwinding the stack out from under code that doesn't expect it. Instead, let's just crash so we can get a stack trace and fix it.

diffstat:

 Adium.xcodeproj/project.pbxproj |   6 +++
 Source/AIAdium.m                |   1 +
 Source/AIObjectDebug.h          |  13 ++++++
 Source/AIObjectDebug.m          |  60 ++++++++++++++++++++++++++++++
 Source/AIStringDebug.m          |   6 +-
 5 files changed, 83 insertions(+), 3 deletions(-)

diffs (156 lines):

diff -r b460f92b53cf -r 4fff1c47e9f2 Adium.xcodeproj/project.pbxproj
--- a/Adium.xcodeproj/project.pbxproj	Sun May 24 02:18:56 2009 -0400
+++ b/Adium.xcodeproj/project.pbxproj	Sun May 24 01:06:52 2009 -0700
@@ -1377,6 +1377,7 @@
 		636D94090E4EAB9D00E5F558 /* AIContactObserverManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 34555C5F0DB6BCE500649CD4 /* AIContactObserverManager.m */; };
 		637864550F9BE1AB0040DEDA /* AutoHyperlinks.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 3496A8EA07CE6CA30055BBAB /* AutoHyperlinks.framework */; };
 		638392F809D4D67A0067B9B7 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 638392F609D4D67A0067B9B7 /* Sparkle.framework */; };
+		638BC1FC0FC932E000CE7600 /* AIObjectDebug.m in Sources */ = {isa = PBXBuildFile; fileRef = 638BC1FB0FC932E000CE7600 /* AIObjectDebug.m */; };
 		639484590EB13DFE008CB6DE /* AIContactHidingController.m in Sources */ = {isa = PBXBuildFile; fileRef = 661561640D84AEEC004B7946 /* AIContactHidingController.m */; };
 		6394845B0EB13E04008CB6DE /* AIContactHidingController.h in Headers */ = {isa = PBXBuildFile; fileRef = 661561630D84AEEC004B7946 /* AIContactHidingController.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		639DF7710F97E61D003C9A32 /* CBPurpleServicePlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B7F278A05440C8D00CDFC90 /* CBPurpleServicePlugin.m */; };
@@ -4405,6 +4406,8 @@
 		636D936A0E4E9FD300E5F558 /* AdiumAddressBookAction_ICQ.scpt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.scpt; name = AdiumAddressBookAction_ICQ.scpt; path = "Frameworks/Adium Framework/Resources/AdiumAddressBookAction_ICQ.scpt"; sourceTree = "<group>"; };
 		636D936B0E4E9FD300E5F558 /* AdiumAddressBookAction_AIM.scpt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.scpt; name = AdiumAddressBookAction_AIM.scpt; path = "Frameworks/Adium Framework/Resources/AdiumAddressBookAction_AIM.scpt"; sourceTree = "<group>"; };
 		638392F609D4D67A0067B9B7 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Sparkle.framework; path = Frameworks/Sparkle.framework; sourceTree = "<group>"; };
+		638BC1FA0FC932E000CE7600 /* AIObjectDebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIObjectDebug.h; path = Source/AIObjectDebug.h; sourceTree = "<group>"; };
+		638BC1FB0FC932E000CE7600 /* AIObjectDebug.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIObjectDebug.m; path = Source/AIObjectDebug.m; sourceTree = "<group>"; };
 		639DFB440F981C7C003C9A32 /* NSCalendarDate+ISO8601Parsing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSCalendarDate+ISO8601Parsing.h"; path = "Frameworks/AIUtilities Framework/Source/NSCalendarDate+ISO8601Parsing.h"; sourceTree = "<group>"; };
 		63A3A9670F9C35D3006C9CB0 /* AIUtilities_Framework.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = AIUtilities_Framework.plist; sourceTree = "<group>"; };
 		63A3A9690F9C35D3006C9CB0 /* ca */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = ca; path = ca.lproj/Localizable.strings; sourceTree = "<group>"; };
@@ -5416,6 +5419,8 @@
 				9ECB03E309F2A9D800996F44 /* AIDictionaryDebug.m */,
 				34A1B2C10DFDBA1200AC78CF /* AIStringDebug.h */,
 				34A1B2C20DFDBA1200AC78CF /* AIStringDebug.m */,
+				638BC1FA0FC932E000CE7600 /* AIObjectDebug.h */,
+				638BC1FB0FC932E000CE7600 /* AIObjectDebug.m */,
 				34BC8F780ACA3AAC00562745 /* AIScannerDebug.h */,
 				34BC8F790ACA3AAC00562745 /* AIScannerDebug.m */,
 				34575E3607CBA874004A4FFF /* DebugWindow.nib */,
@@ -10418,6 +10423,7 @@
 				1121B29A0F896A720047EC66 /* AIContactVisibilityControlPlugin.m in Sources */,
 				112E7FA60FC86BB400657119 /* AITwitterActionsHTMLFilter.m in Sources */,
 				11A2F1220FC8FC9D00C3F05C /* AIMessageAlertsAdvancedPreferences.m in Sources */,
+				638BC1FC0FC932E000CE7600 /* AIObjectDebug.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff -r b460f92b53cf -r 4fff1c47e9f2 Source/AIAdium.m
--- a/Source/AIAdium.m	Sun May 24 02:18:56 2009 -0400
+++ b/Source/AIAdium.m	Sun May 24 01:06:52 2009 -0700
@@ -396,6 +396,7 @@
     [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:ADIUM_FORUM_PAGE]];
 }
 - (IBAction)showXtras:(id)sender{
+	[[AIXtrasManager sharedManager] fhqwhgads];
 	[[AIXtrasManager sharedManager] showXtras];
 }
 
diff -r b460f92b53cf -r 4fff1c47e9f2 Source/AIObjectDebug.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Source/AIObjectDebug.h	Sun May 24 01:06:52 2009 -0700
@@ -0,0 +1,13 @@
+//
+//  AIStringDebug.h
+//  Adium
+//
+//  Created by David Smith on 5/24/2009
+//  Copyright 2009 The Adium Team. All rights reserved.
+//
+
+ at interface AIObjectDebug : NSObject {
+
+}
+
+ at end
diff -r b460f92b53cf -r 4fff1c47e9f2 Source/AIObjectDebug.m
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Source/AIObjectDebug.m	Sun May 24 01:06:52 2009 -0700
@@ -0,0 +1,60 @@
+/*
+ *  AIObjectDebug.m
+ *  Adium
+ *
+ * Created by David Smith on 5/24/2009
+ * This class is explicitly released under the BSD license with the following modification:
+ * It may be used without reproduction of its copyright notice within The Adium Project.
+ *
+ * This class was created for use in the Adium project, which is released under the GPL.
+ * The release of this specific class (AIObjectDebug) under BSD in no way changes the licensing of any other portion
+ * of the Adium project.
+ *
+ ****
+ Copyright (c) 2008, Evan Schoenberg
+ Copyright (c) 2009, The Adium Team
+ All rights reserved.
+ 
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+ 
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 
+ in the documentation and/or other materials provided with the distribution.
+ Neither the name of Adium nor the names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+ 
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#import "AIObjectDebug.h"
+
+#ifdef DEBUG_BUILD
+#import <objc/objc-class.h>
+#endif
+
+ at implementation AIObjectDebug
+
+#ifdef DEBUG_BUILD
+
++ (void)load
+{
+	method_exchangeImplementations(class_getInstanceMethod(self, @selector(doesNotRecognizeSelector:)), class_getInstanceMethod([NSObject class], @selector(doesNotRecognizeSelector:)));
+}
+
+- (void)doesNotRecognizeSelector:(SEL)aSelector
+{
+	if (sel_isEqual(aSelector, @selector(description)) || sel_isEqual(aSelector, @selector(doesNotRecognizeSelector:))) {
+		//we're hosed.
+		NSLog(@"Avoiding infinite recursion in doesNotRecognizeSelector:");
+	} else {
+		NSLog(@"%@ of class %@ does not respond to selector %s", self, [self class], aSelector);
+	}
+	*((int*)0xdeadbeef) = 42;
+}
+
+#endif
+ at end
diff -r b460f92b53cf -r 4fff1c47e9f2 Source/AIStringDebug.m
--- a/Source/AIStringDebug.m	Sun May 24 02:18:56 2009 -0400
+++ b/Source/AIStringDebug.m	Sun May 24 01:06:52 2009 -0700
@@ -2,12 +2,12 @@
  *  AIStringDebug.m
  *  Adium
  *
- *  Created by Evan Schoenberg on 6/9/08.
+ * Created by Evan Schoenberg on 6/9/08.
  * This class is explicitly released under the BSD license with the following modification:
  * It may be used without reproduction of its copyright notice within The Adium Project.
  *
  * This class was created for use in the Adium project, which is released under the GPL.
- * The release of this specific class (AIDictionaryDebug) under BSD in no way changes the licensing of any other portion
+ * The release of this specific class (AIStringDebug) under BSD in no way changes the licensing of any other portion
  * of the Adium project.
  *
  ****
@@ -41,7 +41,7 @@
 
 + (void)load
 {
-	method_exchangeImplementations(class_getInstanceMethod(self, @selector(stringByAppendingString:)), class_getInstanceMethod(NSClassFromString(@"NSCFDictionary"), @selector(stringByAppendingString:)));
+	method_exchangeImplementations(class_getInstanceMethod(self, @selector(stringByAppendingString:)), class_getInstanceMethod(NSClassFromString(@"NSCFString"), @selector(stringByAppendingString:)));
 }
 
 + (void)breakpoint




More information about the commits mailing list