sunday1990 / baymaxprotector Goto Github PK
View Code? Open in Web Editor NEWCrash protector -take care of your application like BayMax
License: MIT License
Crash protector -take care of your application like BayMax
License: MIT License
堆栈如下:
[AnyHashable("StringOutOfBounds"): *** -[__NSCFConstantString substringFromIndex:]: Index 10 out of bounds; string length 10]
代码如下:
extension NSString {
func convertBirthdayToAge() -> Int {
return (self as String).convertBirthdayToAge()
}
}
func convertBirthdayToAge() -> Int {
if self.count == 0 { return 0 }
let dateformatter = DateFormatter()
dateformatter.dateFormat = "yyyy-MM-dd"
let birthday = dateformatter.date(from: self) //崩溃在这一行
if birthday == nil { return 0 }
let interval = birthday!.timeIntervalSinceNow
let age = UInt8(fabs(trunc(interval / (60 * 60 * 24) / 365)))
return Int(age)
}
//调用
[@"1970-01-01" convertBirthdayToAge];
在forwardTargetForSelector中打印堆栈,不还是消息转发的堆栈吗,看不到完整的调用信息
大佬,您好。我的项目里同时集成了你的库还有七牛的PLShortVideoKit,发现录制视频后导出会crash,如果不开启你的库是不会有问题的,是否在做hook操作的时候影响到了。你可以下载七牛的短视频demo,然后集成大白进去会必现这个问题。
NSString防护是有问题的。本来是仿crash,结果到处都是crash,不但保护没有防止crash,反而增加了一堆不改crash的崩溃。
TestContainerVC.m->- (void)testMutableArray-> //1、objectAtIndex:
NSMutableArray *array1 = [NSMutableArray arrayWithObjects:@"1",@"2",@"3",@"4", nil];
NSString *objectAtIndex = [array1 objectAtIndex:5];
objectAtIndex = array1[4];
崩溃在objectAtIndex = array1[4];,并未进行处理
如题
我的测试中,加入两个kvo属性runMode和readPointerAddress,当字符串较短的时候是NSTaggedPointerString类型,较长的时候是__NSCFString类型。
(lldb) po [NSStringFromSelector(@selector(runMode)) class]
NSTaggedPointerString
(lldb) po [NSStringFromSelector(@selector(readPointerAddress)) class]
__NSCFString
若在keyPath中使用__weak,__NSCFString类型的属性,在后续的getKVOInfosForKeypath操作中,对应取出来的KVOInfo->_keyPath为nil,去掉__weak则不会变成nil。而NSTaggedPointerString类型不受影响。
引入现有项目中,奔溃在nstimer这里, BMP_SuppressPerformSelectorLeakWarning(
[_aTarget performSelector:_aSelector];
);
Thread 1: EXC_BAD_ACCESS (code=1, address=0xd69546e88)错误
2、根据操作的protectionType获取对应的IMP,然后判断该IMP在不在原有的impList中,在的话,说明该防护之前没有开启过,不在的话,说明该防护之前开启过。
if (!BMP_ImpExistInList(impList, imp)) {
NSLog(@"关闭保护");
//再执行一次交换操作
[self openProtectionsOn:protectionType catchErrorHandler:nil];
}else{//说明该方法没有被交换,即没有列在保护名单里,空处理即可
NSString * duplicateClose = [NSString stringWithFormat:@"[%@] Is Not In The Protection State Before And Don't Need To Close This Protection Again",protectionName];
[[BayMaxDebugView sharedDebugView]addErrorInfo:@{@"waring":duplicateClose}];
}
如果防护之前开启过,你会再执行一次交换操作,但是你并没有把交换后的方法和之前的方法换回来
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.