MailCore / mailcore2

MailCore 2 provide a simple and asynchronous API to work with e-mail protocols IMAP, POP and SMTP. The API has been redesigned from ground up.
Other
2.59k stars 623 forks source link

[Bug] - iOS app crash #1992

Open yedexiong opened 7 months ago

yedexiong commented 7 months ago

Summary

Platform(s)

<iOS>

Happens on Mail Server

<Gmail>
<iCloud>

Piece of code

#19 Thread

SIGABRT

0
libsystem_kernel.dylib
___pthread_kill + 8

3
libsystem_c.dylib
_err
4
libiconv_std.dylib
0x0000000243161000 + 7336
5
libiconv_std.dylib
0x0000000243161000 + 6048
6
libiconv.2.dylib
___bsd_iconv + 76

7
lepMixedConv(char const*, char const*, char const*, unsigned long, char*, unsigned long*) (MCData.cpp:765)
8

charconv (charconv.c:173)
9

mailmime_encoded_phrase_parse (mailmime_decode.c:144)
10

mailcore::String::stringByDecodingMIMEHeaderValue(char const*) (MCString.cpp:1155)
11

mailcore::AbstractPart::importIMAPFields(mailimap_body_fields*, mailimap_body_ext_1part*) (MCAbstractPart.cpp:222)

mailcore::IMAPPart::importIMAPFields(mailimap_body_fields*, mailimap_body_ext_1part*) (MCIMAPPart.cpp:181)
13

mailcore::IMAPPart::attachmentWithIMAPBody1PartBasic(mailimap_body_type_basic*, mailimap_body_ext_1part*) (MCIMAPPart.cpp:207)
14
mailcore::IMAPPart::attachmentWithIMAPBody1Part(mailimap_body_type_1part*, mailcore::String*) (MCIMAPPart.cpp:121)
15
mailcore::IMAPPart::attachmentWithIMAPBodyMultipart(mailimap_body_type_mpart*, mailcore::String*) (MCIMAPPart.cpp:270)
16
mailcore::IMAPPart::attachmentWithIMAPBodyInternal(mailimap_body*, mailcore::String*) (MCIMAPPart.cpp:107)
17

mailcore::IMAPPart::attachmentWithIMAPBody(mailimap_body*) (MCIMAPPart.cpp:95)
18

msg_att_handler(mailimap_msg_att*, void*) (MCIMAPSession.cpp:2053)
19

mailimap_response_data_parse_progress (mailimap_parser.c:9100)
20

mailimap_cont_req_or_resp_data_parse_progress (mailimap_parser.c:8806)
21

mailimap_response_parse_progress (mailimap_parser.c:929)
22

mailimap_response_parse_with_context (mailimap_parser.c:8970)
23

mailimap_parse_response (mailimap.c:2395)
24

mailimap_fetch_qresync_vanished (qresync.c:402)

mailcore::IMAPSession::fetchMessages(mailcore::String*, mailcore::IMAPMessagesRequestKind, bool, mailimap_set*, mailcore::IndexSet*, mailcore::IndexSet*, unsigned long long, mailcore::HashMap*, mailcore::IMAPProgressCallback*, mailcore::Array*, mailcore::ErrorCode*) (MCIMAPSession.cpp:2373)
26
mailcore::IMAPSession::fetchMessagesByNumberWithExtraHeaders(mailcore::String*, mailcore::IMAPMessagesRequestKind, mailcore::IndexSet*, mailcore::IMAPProgressCallback*, mailcore::Array*, mailcore::ErrorCode*) (MCIMAPSession.cpp:2480)
27
mailcore::IMAPFetchMessagesOperation::main() (MCIMAPFetchMessagesOperation.cpp:114)
28
mailcore::OperationQueue::runOperations() (MCOperationQueue.cpp:123)
29
libsystem_pthread.dylib
__pthread_start + 136

Actual outcome MailCore Cause app crash,How can we solve this problem?I need your help. Thank you!

akkrat commented 7 months ago

we also suffer from this issue on different domains: mail.ru, orange.fr, sapo.pt, hotmail ... Our app crashes on iOS 17.1 and higher

yedexiong commented 7 months ago

we also suffer from this issue on different domains: mail.ru, orange.fr, sapo.pt, hotmail ... Our app crashes on iOS 17.1 and higher

Did you solve it? How was it resolved?

fanta1ty commented 7 months ago

same issue for me

akkrat commented 7 months ago

we also suffer from this issue on different domains: mail.ru, orange.fr, sapo.pt, hotmail ... Our app crashes on iOS 17.1 and higher

Did you solve it? How was it resolved?

Nope 🤷‍♀️

suhastech commented 7 months ago

Same here but on MacOS sonoma mostly

StarsCF commented 7 months ago

Any thoughts on how to fix this, guys?

LKShadow commented 7 months ago

same issue for me

akkrat commented 7 months ago

Seems like it is a Sonoma (14.1+)/iOS (17.1+) issue. Here we can find some directions how to fix it https://github.com/rstudio/rstudio/issues/13908. maybe rebuilding library with all its dependencies with latest compiler could fix the issue

VyNguyen0102 commented 7 months ago

I've tested on iPad pro 11" iOS 17.1.1. without any issue.

triton3 commented 7 months ago

Same issue on iOS 17.1.1 and macOS 14.1.1

@akkrat Just to clarify, are you suggesting that building with latest sdk and Xcode fixed this issue for you?

ju135 commented 7 months ago

This seems to be related to iOS 17.1.1. (Happens when trying to decode a mime mail header with some specific encoding) It's working on iOS 17.2 Beta which will probably be released to public around mid-December

triton3 commented 7 months ago

@ju135 Appreciate the input. Do you know which encoding causes this issue?

ju135 commented 7 months ago

Unfortunately, I'm not sure but I think I found the "bad mail" and this is probably the part of the header that caused the issue.

MIME-Version: 1.0
Content-Type: multipart/alternative;
    boundary="b1_bcd83991a6fb4a8cb33a77395e4ee12d"
Content-Transfer-Encoding: 8bit
X-SES-Outgoing: 2023.11.12-54.240.6.31

This is a multi-part message in MIME format.

--b1_bcd83991a6fb4a8cb33a77395e4ee12d
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

👍 Geld sparen und schlau studieren: Unsere neuesten Studentenangebote 👍

--b1_bcd83991a6fb4a8cb33a77395e4ee12d

👍 is the ASCII representation of the thumbs-up emoji (👍) and is part of the mail subject which has 8-bit as Content-Transfer-Encoding and UTF-8 as charset. So the issue might be the binary-to-text conversion of special characters like emojis.

dinhvh commented 7 months ago

@ju135 could you show the full main headers of this email?

In this situation, I think we need to understand what parameters are passed here: https://github.com/MailCore/mailcore2/blob/7417b2e8dd7e2c028aadb72056e4d1428c0627c4/src/core/basetypes/MCData.cpp#L783

If you have a local repro, it would be easy to figure those out. Then, we would be able to analyze and find a fix for it.

ju135 commented 7 months ago

Yes I'll update my message with the full header later. But I think the issue might already be fixed for users who update to iOS 17.2. Luckily the release to public happened today about an hour ago - so this crash should go away for those who update 🤞

triton3 commented 7 months ago

@ju135 It looks like the iOS update yesterday was v17.1.2 and not 17.2

Would it be possible for you to post the headers of that email so that we get an understanding of what is causing this and check if the iOS 17.1.2 update fixed it?

ju135 commented 7 months ago

@triton3 you are right, I misread that. Unfortunately, I don't know if its already fixed with 17.1.2 Here are all the headers (I censored some parts of it)

Mail Headers ``` Return-Path: <######@eu-west-1.amazonses.com> Received: from ####.###.####.de ([unix socket]) by ####.###.####.de (Cyrus v2.4.22-Invoca-RPM-2.4.22-2.RRZK.el7_9) with LMTPA; Sun, 12 Nov 2023 15:32:56 +0100 X-Sieve: CMU Sieve 2.4 Received: from ####.###.####.de (####.###.####.de [###.##.##.###]) by ####.###.####.de (8.14.7/8.14.7) with ESMTP id ######### for <#####@#####.de>; Sun, 12 Nov 2023 15:32:56 +0100 IronPort-SDR: 6550e217_joguuhcbb6ztbDSae5Jiyt2zK+RkeEu+Sa7bbltgnwq4AK8 lMryE9Q96HrySl2NW2TAb8F+6OITgjkNKLrdG/A== IronPort-Data: A9a23:FRv7jq81KjShxGJyoQ7RDrUDwXaTJUtcMsCJ2f8bNWPcYEJGY0x3z mcXWmvSbPveZWamf49/bYTl9UgP75bdx9cyHFNvqnoxFiIbosfsO4+lIxarNUt+DCFhoGFPt JxCN4aafKjYaleG+39B55C49SEUOZmgH+a6UqifUsxIbVcMYD87jh5+kPIOjIdtgNyoayuAo tqaT/f3YTdJ4BYqdDpPg06/gEk35q+r4WpC5gVWic1j5TcyqVFEVPrzGonsdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6ZvXAdJHAathZ5RlqPgqo DlFncTYpQ7EpcQgksxFO/VTO3gW0aGrZNYriJVw2CCe5xSuTpfi/xlhJH0oPNIoxtp5PXwU0 PgFKxcoXwiD2v3jldpXSsE07igiBMC1edhG/Gpl0SmcCus6B53eBrrH/sMdhXE5g8lcGvDFa tFfYj1qBPjCS0ATfA1LUNRg2rzx7pX8W2UwRFa9/fNvuTCKnAZ6i7a2aoWIc5nVGs4Kk0+S/ Sefojn1R00TPdLamGHfrDfw3bPExXOhUdIfRLP9rqYy2AXL7mEOTQIbTkf++L+wj0esXNREJ ldS8S0rxUQ33Bb1HoigBUPo/xZouDYYRtwXL905xz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bnhPtICOoqTM2ftWvdyQiVxehZhOOIqQEIWReOlNK1vp 0OT0EKMrzN5C9B4/oSjjPVLz9q+qjgzEnhv5am855Cd3ATV51d X-Talos-CUID: 9a23:WNjb+GPESOBVm+5DZDdmq34oJs4Zbyf4yGrTBGqJEWY0V+jA X-Talos-MUID: =?us-ascii?q?9a23=3ANeVGHgwynNjmOJQ9nsKGNOnwc8maqKCzDgcxoZY?= =?us-ascii?q?pgZDeFAZ6JyadtjaIHLZyfw=3D=3D?= X-IronPort-Anti-Spam-Filtered: true Subject: =?utf-8?q?=5BRRZK-Spamverdacht=5D_=F0=9F=91=8D_Geld_sparen_und_schlau_stu?= =?utf-8?q?dieren=3A_Unsere_neuesten_Studentenangebote_=F0=9F=91=8D?= X-UzK-Spam: POSITIVE X-IronPort-AV: E=Sophos;i="6.03,297,1694728800"; d="scan'208,217";a="268952687" X-Amp-Result: SKIPPED(no attachment in message) X-Marked-By: $ACCEPTED X-Spam-Level: *********** X-MGA-submission: =?us-ascii?q?MDE/M1Jsf1R1tsr9zNuyCxvi99q91g8rXPw86N?= =?us-ascii?q?F3J7rS4avmJn+ouCJ2EF2TzFFkOUYdLEZ39/r9ly7H1OtPR00DQWVHzo?= =?us-ascii?q?qdXmOL9mLffWmxJeRF0EjdoGWu+WcQsm1Ym33dPOHBeo8JhF0WnJ0m2a?= =?us-ascii?q?BR?= Received: from #######.eu-west-1.amazonses.com ([###.###.#.##]) by ####.###.de with ESMTP/TLS/AES256-SHA; 12 Nov 2023 15:32:55 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=luoe5atunvdeay44gin2g7pd6cjv4u7q; d=###.com; t=1699799574; h=Date:To:From:Reply-To:Subject:Message-ID:List-Unsubscribe:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=m2NklVnR+GK/Lp0QaFo+9raBBc42Q37R7kMsg2oTVKY=; b=SHVXeNnr8h3ItCP6OOJOL2c6MOOJEp/uT3dJFDNYucTpF3pHdOqrmaTpl5yzFtlN F6rYfDacKvol+CE1Kvpz/3kFtahwgCMuzitBx7WM0nNOpRlvehGcXT+a7YirtaeT/Lu iJggnPCbJDW6AGtf2QTnoE28BqsR4rMvlpf2ytM0= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=shh3fegwg5fppqsuzphvschd53n6ihuv; d=amazonses.com; t=1699799574; h=Date:To:From:Reply-To:Subject:Message-ID:List-Unsubscribe:MIME-Version:Content-Type:Content-Transfer-Encoding:Feedback-ID; bh=m2NklVnR+GK/Lp0QaFo+9raBBc42Q37R7kMsg2oTVKY=; b=bNYsxygrC+Asu/gVOGhOofbXeSsP3xHP/nZORXeNnBV8c3sxsR/l9sXRio/w78Nc yirNSZXhHOueDWEl3PvRuoZWPwUPA721ym/BsAKzJDvAaSzqoVLlNYiAA08KcmQcztZ o01+l8mAFaUa/kL/9GUYVjYVotY41oHRy8iEOcCo= Date: Sun, 12 Nov 2023 14:32:54 +0000 To: "####@####.de" <###@###.de> From: "###.com" Reply-To: "####.com" Message-ID: <###@eu-west-1.amazonses.com> X-Mailer: Sendy (https://sendy.co) List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="b1_bcd83991a6fb4a8cb33a77395e4ee12d" Content-Transfer-Encoding: 8bit Feedback-ID: 1.eu-west-1.8zcmiq6QqA9Ei9VtBISTGwYUfin85SQuy0f0phh4kyY=:AmazonSES X-SES-Outgoing: 2023.11.12-54.240.6.31 This is a multi-part message in MIME format. --b1_bcd83991a6fb4a8cb33a77395e4ee12d Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 👍 Geld sparen und schlau studieren: Unsere neuesten Studentenangebote 👍 --b1_bcd83991a6fb4a8cb33a77395e4ee12d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable // ... Mail content in html format --b1_bcd83991a6fb4a8cb33a77395e4ee12d-- ```
akkrat commented 7 months ago

@triton3 @ju135

Screenshot 2023-12-06 at 12 55 03
triton3 commented 7 months ago

Unfortunately I have no leads on how to figure out the cause, or the fix. I tried with the headers @ju135 suggested, but it is not crashing on my end using iOS 17.1.2. I do still see new crash reports on firebase even with iOS 17.1.2, so the issue is not yet fixed.

ju135 commented 7 months ago

Now 17.2 was released for real. Updating should fix it.

arminius2 commented 6 months ago

I've stumbled upon this crash while playing with writing a spam filter experiment. Simply allocate a MCOMessageParser with the contents of TestCrashParser.txt (would've attached as text but GitHub wouldn't let me, so obviously extract first) - something like

NSData *testCrashParserData = [NSData dataWithContentsOfFile:@"./TestCrashParser.txt"];
MCOMessageParser *parser = [MCOMessageParser messageParserWithData:testCrashParserData];

And voila, the crash above appears

TestCrashParser.txt.zip

akkrat commented 5 months ago

Bug was fixed on iOS 17.2 update (affected versions: 17.1.*)

Be-Maps commented 5 months ago

we also suffer from this issue on different domains: mail.ru, orange.fr, sapo.pt, hotmail ... Our app crashes on iOS 17.1 and higher

Did you solve it? How was it resolved?

Nope 🤷‍♀️

Hi Artur, Could you check if you see my bug on iOS 17 (just raised it): "iOS: Thread not released by IMAP Session" I have put a class in there on how to recreate. ... Thanks, Walter.