Closed jianfengqiu closed 11 years ago
Looks like one of those variables dereferenced a bad pointer. Are you sure all the variables involved are of class MailCore::String?
How do you reproduce the issue?
@dinhviethoa run below code several time can reproduce it.
for (int i = 0; i < _loadedMessages.count ; i++) {
MCOIMAPMessage *msg = [_loadedMessages objectAtIndex:[_loadedMessages count]-1-i];
MCOMessageParser * parser = [[_vcMailboxes.dictMessagesContent objectForKey:[_dictAccount objectForKey:@"email"]] objectForKey:[NSString stringWithFormat:@"%u",msg.uid]];
NSArray *emailContentArray = [self flattenHtmlAndRemoveHeader:[parser htmlRenderingWithDelegate:nil]];
[_loadedEmailContent setObject:emailContentArray forKey:[NSString stringWithFormat:@"%u",msg.uid]];
}
- (NSArray *)flattenHtmlAndRemoveHeader:(NSString *)string
{
NSString *tempString = [[string mco_flattenHTML] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSLog(@"tempString:%@",tempString);
// remove head info
NSRange range = [tempString rangeOfString:@"PDT"];
NSUInteger end = range.location + range.length;
NSString *stringWithoutHeader = [tempString substringFromIndex:end];
NSArray *stringArray = [stringWithoutHeader componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
NSMutableArray *finalStringArray = [NSMutableArray array];
for (NSString *subString in stringArray) {
NSString *tempString = [subString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
[finalStringArray addObject:tempString];
}
NSMutableArray *finalArray = [NSMutableArray array];
for (NSString *string in finalStringArray) {
if (![string isEqualToString:@""]) {
[finalArray addObject:string];
}
}
NSLog(@"resultString: %@",finalArray);
return finalArray;
}
Could you minimize that code to extract only what makes it crash? Additionally, if it's due to a given message, could you attach it? Thanks.
I think this method [string mco_flattenHTML] cause the crash. Especially call this method in a for loop. It's not due to a given message.
Which string does it fail with?
The string is probably generated from the content of a message.
Could you find the message that cause the failure?
Thanks.
Hoà V. Dinh
On Sunday, June 23, 2013 at 7:30 PM, jianfengqiu wrote:
I think this method [string mco_flattenHTML] cause the crash. It's not due to a given message.
— Reply to this email directly or view it on GitHub (https://github.com/MailCore/mailcore2/issues/141#issuecomment-19886358).
Sorry I can not catch which string fail. But the string is the return from [parser htmlRenderingWithDelegate:nil]
Could you NSLog() each string (or message) before you pass them to mco_flattenHTML? The last one you sent through mco_flattenHTML before crashing should show. The last one is the string that will cause the failure. Copy-paste the content of the string (or the source of the message) to a file and send it to me. Thanks.
ok, thanks!
I can not reproduce it now. I need more test about it.
@dinhviethoa I catched the string which I pass to mco_flattenHTML, then crash shows up. But it is too long to paste here. Can I email it to you? My email is jianfengqiu@gmail.com Thank you very much.
Can you reproduce it?
@dinhviethoa Yes, I can. It only happened when the htmlString is very long. And also I used your approach to minimize the code and test it. The result was no crash. So I used another flattenHtml method to test and find that works great. I have no idea about it. I will test more to figure out why this issue happened. If I found interesting something, I will email you.
If that results in no crash, you should reintroduce back the code you removed progressively until it crashes.
I'm getting this error randomly too. I will try and locate a sample message for you.
When you get that crash, could you get the value of mUnicodeChars, mLength, suffix->mUnicodeChars, suffix->mLength? Thanks!
Any update on it?