Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash at launch Xcode 16 iOS 18 - EXC_BAD_ACCESS 0x100b63934 (0x100b638e0 + 84) specialized withCheckedContinuation<A>(isolation:function:_:) #4177

Closed
7 of 12 tasks
joaopdcgarcia opened this issue Aug 13, 2024 · 44 comments
Assignees
Labels

Comments

@joaopdcgarcia
Copy link

joaopdcgarcia commented Aug 13, 2024

Describe the bug
Crashes at launch with a not so useful stacktrace.

RevenueCat 4.43.2 Xcode 16 beta 5 + iOS 18 crash

  1. Environment
    1. Platform: iOS
    2. SDK version: 4.43.2.
    3. StoreKit version:
      • StoreKit 1
      • StoreKit 2 (enabled with usesStoreKit2IfAvailable(true))
    4. OS version: 18
    5. Xcode version: 16 beta 5
    6. Device and/or simulator:
      • Device
      • Simulator
    7. Environment:
      • Sandbox
      • TestFlight
      • Production
    8. How widespread is the issue. Percentage of devices affected.
      100%
  2. Debug logs that reproduce the issue.

No logs, just this stacktrace.

  1. Steps to reproduce, with a description of expected vs. actual behavior

Launch the app.

  1. Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)
<compiler-generated>
specialized withCheckedContinuation<A>(isolation:function:_:)

image

image

  1. Additional context
    Add any other context about the problem here.

We want to keep supporting iOS 12. Is the v.4.x of RevenueCat going to be deprecated?

@RCGitBot
Copy link
Contributor

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

@MarkVillacampa
Copy link
Member

MarkVillacampa commented Aug 13, 2024

Hello @joaopdcgarcia,

Is the issue only reproducing for you in TestFlight? do you have any more complete stacktrace? With just the one you posted we cannot be sure the crash happens within this SDK's code.

I've not been able to reproduce the issue you describe using Xcode 16.1 beta 2, a simulator running iOS 18.1, a device running iOS 18 beta 6, and version 4.32.2 of the SDK, while compiling in release mode.

@joaopdcgarcia
Copy link
Author

joaopdcgarcia commented Aug 14, 2024

Hello @joaopdcgarcia,

Is the issue only reproducing for you in TestFlight? do you have any more complete stacktrace? With just the one you posted we cannot be sure the crash happens within this SDK's code.

I've not been able to reproduce the issue you describe using Xcode 16.1 beta 2, a simulator running iOS 18.1, a device running iOS 18 beta 6, and version 4.32.2 of the SDK, while compiling in release mode.

One of our QA tester was the only one to reproduce this on TF (he has a lot of transactions not sure if that matters), consistently. If I comment out RevenueCat, it crashes again and that call seems to be done inside RC.
I'm trying to gather logs by upgrading another device to iOS 18. EDIT: Not able to crash on this one either.

I've updated with the full stacktrace

image

We've built with xcode 16 beta 5.

@rosday
Copy link

rosday commented Aug 16, 2024

I am suffering from a similar issue.

It happens when I try to build with Xcode on my own Mac as iOS app adapted to Mac. Other builds in simulators and real devices work fine

RevenueCat 5.2.3
XCode 16 beta 5 and XCode 16.1 beta
MacOS Sonoma 14.5

Edit: Found out some users are having a crash in my Tesflight build, too, running iOS18.1

Tried commenting all my methods to check if I was doing something wrong, but simply calling Purchases.shared.offerings() also crashes the app

Screenshot 2024-08-16 at 11 02 27 Screenshot 2024-08-16 at 11 03 03

@timothygremp
Copy link

timothygremp commented Aug 17, 2024

running xcode 16.1, swift package 5.2.3, issue occuring for me as well. This is line in debugger where dies after: DEBUG: ℹ️ Warming up intro eligibility cache for 2 products.

Where error throws:

static func call<Value, Error: Swift.Error>(
method: (@escaping @sendable (Result<Value, Error>) -> Void) -> Void
) async throws -> Value {
return try await withCheckedThrowingContinuation { continuation in
@sendable
func complete(_ result: Result<Value, Error>) {
continuation.resume(with: result)
}

        method(complete)
    }
}

@MarkVillacampa
Copy link
Member

MarkVillacampa commented Aug 19, 2024

Thank you for the additional information @timothygremp @rosday @joaopdcgarcia

I have been able to reproduce the issue, but only in a very limited scenario.

The following snippet is enough to force the crash:

_ = await withCheckedContinuation { continuation in
    continuation.resume(returning: true)
}

I can reproduce on Xcode 16 beta 5 and Xcode 16.1 beta 1, but ONLY when running the app as "Designed for iPhone/iPad" on macOS Sonoma, and ONLY in debug mode (crash goes away in release mode).

I cannot reproduce by running on iOS 17 or 18 neither device nor simulator, and cannot reproduce either when running on macOS Sequoia beta.

I have not been able to test the scenario where it crashes when installed via TestFlight, but I'm confident it's triggered by the same bug.

Has any of you been able to reproduce the issue locally in a scenario that does not involve running as "Designed for iPhone/iPad"?

@kristofferbv
Copy link

Has any of you been able to reproduce the issue locally in a scenario that does not involve running as "Designed for iPhone/iPad"?

@MarkVillacampa, I’ve been facing a similar issue and can reproduce it on my iPhone running iOS 18 beta 4. The crash only occurs in Xcode 16.0 Beta 5.

image image

@SAllen0400
Copy link

I'm also seeing a crash on withCheckedThrowingContinuation. I didn't experience this crash personally, but a member of my team is crashing on launch in Test Flight (They are on iOS 18 - beta 3).

I am running version 5.2.3 of the RevenueCat SDK. The minimum deployment target for my project is iOS 18.

Here's the stack trace and code snippet from the Test Flight crash report (again, I have not been able to recreate myself):

Screenshot 2024-08-19 at 11 02 49 AM Screenshot 2024-08-19 at 11 03 09 AM

@rudrankriyam
Copy link

It is fixed in Xcode 16 Beta 6!

@rosday
Copy link

rosday commented Aug 21, 2024

It is fixed in Xcode 16 Beta 6!

It still crashes for me

@MarkVillacampa
Copy link
Member

@rudrankriyam Unfortunately, I can still reproduce in Xcode 16 beta 6 by running the app in a Sonoma host as "Designed for iPhone/iPad". Can you confirm if it crashes for you in that scenario?

@SAllen0400 @kristofferbv you're both right, it also crashes in withCheckedThrowingContinuation. I will update issue report.

@rudrankriyam
Copy link

Hey @MarkVillacampa and @rosday, I updated my phone to iOS 18 Beta 7 too, and it is not crashing on it. Unfortunately, as you mentioned, it is crashing on other OSes, or previous betas. :/

@MarkVillacampa
Copy link
Member

@rudrankriyam thanks for the clarification!

I have not been able to reproduce the crash on device by running from Xcode (I have not been able to test via TestFlight tho). If you're able to repro on device, could you describe the combination of Xcode and iOS versions?

@rudrankriyam
Copy link

@MarkVillacampa I was using Xcode 16 Beta 5 + iOS 18 Beta 6 where the crash was happening. I realised it when it started crashing on TestFlight where Xcode Cloud was using Beta 5. After updating to iOS 18 Beta 7 and Xcode 16 Beta 5, I am not seeing any withCheckedThrowingContinuation both for my code and RC's SDK

@MarkVillacampa
Copy link
Member

Xcode 16 RC just came out and I am still able to reproduce the crash when running as "Designed for iPhone/iPad" on Sonoma.

I would like to know if anybody is still able to reproduce the issue when running the app in a different scenario (e.g. via TestFlight when running on iOS 17 or iOS 18 RC).

@brendand
Copy link

brendand commented Sep 11, 2024

One of my TestFlight beta testers is getting a similar crash when running on macOS Sequoia public beta macOS 15.0 (24A5298h).

Was using RevenueCat 4.43.2. I've just updated to the main branch to see if that helps.

Thread 4 Crashed:
0   Tap Forms Pro                 	0x000000010064e458 specialized withCheckedContinuation<A>(isolation:function:_:) + 40 (/<compiler-generated>:0)
1   Tap Forms Pro                 	0x000000010064e458 specialized static Async.call<A>(method:) + 92 (AsyncExtensions.swift:105)
2   Tap Forms Pro                 	0x000000010052871d closure #1 in CustomerInfoManager.getCustomerInfo(appUserID:isAppBackgrounded:completion:) + 1 (CustomerInfoManager.swift:352)
3   Tap Forms Pro                 	0x00000001004caf39 partial apply for closure #1 in DefaultNetworkImageLoader.image(from:) + 1 (/<compiler-generated>:0)
4   Tap Forms Pro                 	0x00000001004d360d specialized thunk for @escaping @isolated(any) @callee_guaranteed @async () -> (@out A) + 1 (/<compiler-generated>:0)
5   Tap Forms Pro                 	0x00000001004cc65d partial apply for closure #1 in NSURLSession.data(from:) + 1
6   libswift_Concurrency.dylib    	0x00000002627328a5 completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*) + 1 (Task.cpp:471)

He can no longer launch the app since it's calling into RevenueCat upon launch.

I know this is an iOS 18 thread, but thought I'd mention that it's also happening on macOS.

@carloscabanero
Copy link

Ran into this issue when we started testing iOS 18. Same as described under same conditions: Running on device, works under simulator, we can still reproduce running Xcode 16 RC and iOS 18 beta on devices. I couldn't reproduce when building on Xcode 15 and running on iOS 18.

A couple more notes in case it helps and our workaround:

  • Note I said Xcode 16 RC and iOS 18 beta. We noticed if there is a mismatch between the versions, then it will crash. Ie, running Xcode 16 RC and iOS 18 RC works. Xcode 16RC and iOS 18 beta, won't work. I think this is consistent with what others reported here or why the issue seems to stop when they update one of the sides (like @rudrankriyam). No idea why.
  • We noticed in the backtrace that there were some calls being done to SK2, which we thought we had removed. Removing usingStoreKit2IfAvailable fixes the issue. We also tested and this is independent of the Xcode - iOS version you run. So check and remove it, may help you as well to get rid of it completely (I think this is what @SAllen0400 may be running into?)

Hope this helps.

@rudrankriyam
Copy link

From iOS 18 Beta 7, the issue is fixed from Apple side so hopefully the public release of iOS 18 will not have this issue. I still see crashes on TestFlight but from users who are using iOS 18 Beta 6 or below.

@pewebapps
Copy link

pewebapps commented Sep 15, 2024

Is there going to be an update from RevenueCat on this? I pushed a new release out using the Xcode 16 RC without knowing this issue and have since experienced lots of crashes. For an indie developer, I don’t have QA’s etc and so I am disappointed that this issue wasn’t communicated to me and my fellow developers. A big problem like this makes me lose complete trust in RevenueCat.

@dfed
Copy link

dfed commented Sep 16, 2024

I'm seeing this crash in Xcode 16 GM when targeting macOS 14.6.1 on a "built for iPad" app.

@teeeeeegz
Copy link

teeeeeegz commented Sep 17, 2024

I am also experiencing this crash with users on iOS 18, compiled with Xcode 16 RC. However, I can't confirm whether those users are on an iOS 18 Beta.

CleanShot 2024-09-17 at 13 15 24@2x
CleanShot 2024-09-17 at 13 14 12@2x

@MilesV64
Copy link

MilesV64 commented Sep 17, 2024

I'm also experiencing this in production on iOS 18 compiled with Xcode 16 RC, this needs to be fixed ASAP. I see users on both iOS 18 and 18.1 affected.

@cnordvik
Copy link

We have 1900 crashes since iOS 18 launched with this error... at least 5 people say they are on the release of iOS 18 and it still crashes in our support inbox.

CleanShot 2024-09-17 at 18 43 24@2x

@jeiting
Copy link
Contributor

jeiting commented Sep 17, 2024

Hey all, sorry we didn't have eyes on this until right now. We've got an incident going internally and should have some updates shortly.

@jeiting
Copy link
Contributor

jeiting commented Sep 17, 2024

We're seeing this particular exception pop-up in the traces of a few other SDKs. It seems to be triggered by multiple SDKs.

airbnb/lottie-ios#2472
aws-amplify/amplify-swift#3806

We're trying to understand more and see if we can mitigate it with an SDK release. It's related to async / await, and reverting to using only the completion block methods might mitigate the issue.

@aboedo
Copy link
Member

aboedo commented Sep 17, 2024

Hey folks, we're still digging into this.

We haven't been able to reproduce it locally, however.

In the past, we've only been able to produce in a very specific situation, which is running a combination of Xcode 16 beta, macOS apps designed for iPad, and debug builds. I realize that might not be the situation that's causing it for you.

As far as we can tell, the issue is caused by an underlying bug in Swift, triggered when calling withCheckedThrowingContinuation, which is what we use to bridge the gap between Swift Concurrency and completion blocks.

So there is a chance that you might avoid this crash by either:

  • sticking to the completion blocks APIs (i.e.: use getCustomerInfo(completion:) instead of await customerInfo()
  • sticking to Xcode 15

However, since we haven't been able to reproduce yet, we can't assert that either of those is guaranteed to work.

@cnordvik or any of the folks in this thread, if you are seeing this in your crashlytics, would you be open to adding me to your account, or otherwise having a call with me to show me the details, so we can dig in deeper and figure this one out?

@aboedo
Copy link
Member

aboedo commented Sep 18, 2024

Hey folks, we believe that #4286 might fix this. Could you give it a shot and let us know if it fixes the issue for you?

All you’d need to do is to update your SDK version to use the use-withUnsafeThrowingContinuation branch

@minlite
Copy link

minlite commented Sep 18, 2024

I filed FB14768097 with Apple on August 12, 2024. It was this exact same bug when compiling with Xcode 16b5 and running on first iOS 18.1 Beta.

They never responded to me but it was fixed on the next iOS 18.1 beta, so I just assumed the patch would be applied on the iOS 18.0 train as well to make sure it's ready for launch. Looks like Apple actually forgot to apply the patch to 18.0 train and left it in prod.

Good news is that iOS 18.1 will be released in ~1.5 weeks and should fix it, but bad news is it's gonna make people not able to use Xcode 16 until then.

My initial bug report in amplify-swift repo

@oryonatan
Copy link

oryonatan commented Sep 18, 2024

@aboedo
Copy link
Member

aboedo commented Sep 18, 2024

Looks like temporarily moving to withUnsafeContinuation and withUnsafeThrowingContinuation might do the trick. We've updated the #4286 to do that, if you wanna give it a shot

@OlKir
Copy link

OlKir commented Sep 19, 2024

Could this be connected with swiftlang/swift#75771 (comment) ?
I can confirm that we also:

  1. Have crash reports related to withThrowingTaskGroup
  2. They started to appear before official iOS 18 release and happen only on iOS 18
  3. We can't reproduce them ourselves even with artificial heavy load multithreading scenarios
  4. In Xcode Organizer they are attributed to 22A5282m which is iOS beta
  5. Number of crashes has not significantly increased after iOS 18 public release (which was our biggest fear)

@kgaidis
Copy link

kgaidis commented Sep 19, 2024

For more data points, my app had instant, repeating (5+ per user), withCheckedThrowingContinuation crashes when building off Xcode 16 (non-beta) for users. Had to do an emergency release with Xcode 15.4 and that seems to resolve it. It doesn't seem safe to use Xcode 16?

@fire-at-will
Copy link
Contributor

@kgaidis Thanks for reporting!

For the app version that crashed for users, what version of the RevenueCat SDK was the app using? I'm curious if it contained the change in #4286 that migrated the SDK's calls from withCheckedThrowingContinuation to withUnsafeThrowingContinuation.

@kgaidis
Copy link

kgaidis commented Sep 19, 2024

@fire-at-will 5.2.0 (not the newest), and note that I am not even sure its RevenueCat - I think this is just an overall iOS/Xcode 16 "crisis" where any use of this could be broken? I have a lot of my own code + other third-party SDK's. I am purely commenting to warn others that I am not sure if Xcode 16 is safe for anything.

@emcro
Copy link

emcro commented Sep 19, 2024

I just had a report from a user with this same issue on my Catalyst update shipped with Xcode 16 RC, using RC v4.30.5.

@theolampert
Copy link

Another datapoint, we also ran into this this week. I updated our CI from Xcode 15.4 to 16.0 and the Test Flight build crashed on launch for someone internally who was testing the build. The person testing was on an 18.1 beta. Downgrading Xcode appears to have resolved the issue.

@leonsas
Copy link

leonsas commented Sep 26, 2024

+1 We're seeing the same issue on all of our calls to withCheckedContinuation calls, including this one from RevenueCat.

CleanShot 2024-09-26 at 14 43 10@2x

Stack trace:

Thread 14 Crashed:
0   Nyx                           	0x00000001034cdc84 specialized withCheckedThrowingContinuation<A>(isolation:function:_:) + 108
1   Nyx                           	0x000000010359fb71 Purchases.logOut() + 1
2   Nyx                           	0x0000000102a9c3e1 specialized static SubscriptionHelper.isActiveInRevenueCat() + 1 (SubscriptionHelper.swift:44)
3   Nyx                           	0x00000001029c9919 closure #1 in SubscriptionBridge.setShouldShowMainPaywall(shouldShow:) + 1 (SubscriptionBridge.swift:16)
4   Nyx                           	0x00000001029c2e79 $sxIeAgHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTRytSg_TG5TATQ0_ + 1 (/<compiler-generated>:0)
5   Nyx                           	0x00000001029bd1b5 $sxIeAgHr_xs5Error_pIegHrzo_s8SendableRzlTRyt_Tg5TQ0_ + 1 (/<compiler-generated>:0)
6   Nyx                           	0x00000001029c3975 $sxIeAgHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTRyt_Tg5TA.16TQ0_ + 1
7   libswift_Concurrency.dylib    	0x00000001a85186c5 completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*) + 1 (Task.cpp:471)

This is built on Xcode 16 and issue only happening on iOS18.
Libraries:

package.json:
  react-native-purchases="7.0.0"

podfile.lock
PurchasesHybridCommon (7.0.0):
   RevenueCat (= 4.27.0)

@Mthomas3
Copy link

Mthomas3 commented Oct 5, 2024

is it fixed? I'm still getting the crash

@RaimundasSakalauskas
Copy link

We have this crash in our app if we compile with xcode 16 as well. Works fine if xcode 15 is used to cut the archive. This is our number 1 crash at the moment (for the build that used xcode 16 before we switched back to xcode 15).

@aboedo
Copy link
Member

aboedo commented Oct 7, 2024

Hey folks, sorry that we haven't updated this thread.

Have you found instances of this happening on stable builds of iOS 18? So far we've only had reports of the crash happening in beta builds.

If you have seen the instances, could you update to the latest stable version of our SDK? The fix should be deployed and the problem should go away.

If it hasn't, please let us know so we can dig deeper.

@aboedo aboedo self-assigned this Oct 7, 2024
@aboedo
Copy link
Member

aboedo commented Oct 7, 2024

There's a more thorough explanation about the underlying mechanism here, which also points to the original issue only happening in earlier iOS 18 betas.
The fix that was shipped in the latest iOS SDK should help regardless.

I'll tentatively mark this issue as closed, but feel free to reopen if you experience crashes after upgrading the SDK and / or when running the latest stable builds of iOS

@aboedo aboedo closed this as completed Oct 7, 2024
@ricsantos
Copy link

@aboedo

The fix that was shipped in the latest iOS SDK should help regardless.

Just wondering, does that include 4.43.3?

@ricsantos
Copy link

I've just seen this crash popup again for a user running iOS 18.0 (could be beta, not sure) built in Xcode 16 with RevenueCat 4.43.3.

          Crashed: com.apple.root.user-initiated-qos.cooperative
0  RevenueCat                     0x5f638 $ss31withCheckedThrowingContinuation9isolation8function_xScA_pSgYi_SSyScCyxs5Error_pGXEtYaKlFTwbShy10RevenueCat15SK2StoreProductVG_Tg5 + 108
1  libswift_Concurrency.dylib     0x5e950 swift::runJobInEstablishedExecutorContext(swift::Job*) + 252
2  libswift_Concurrency.dylib     0x5fe5c swift_job_runImpl(swift::Job*, swift::SerialExecutorRef) + 76
3  libdispatch.dylib              0x15d94 _dispatch_root_queue_drain + 392
4  libdispatch.dylib              0x16598 _dispatch_worker_thread2 + 156
5  libsystem_pthread.dylib        0x4c40 _pthread_wqthread + 228
6  libsystem_pthread.dylib        0x1488 start_wqthread + 8

Will this fix be backported to RevenueCat 4? cc @codykerns @aboedo

@ijunfly
Copy link

ijunfly commented Nov 24, 2024

Our app doesn't use this SDK, but we're facing issues on iOS 18.0.0, especially when using Xcode downloaded from the App Store.

          Crashed: com.apple.root.user-initiated-qos.cooperative
0  *****                 0x23440c specialized withCheckedThrowingContinuation<A>(isolation:function:_:) + 4347200524 (<compiler-generated>:4347200524)
1  libswift_Concurrency.dylib     0x5e8d4 swift::runJobInEstablishedExecutorContext(swift::Job*) + 252
2  libswift_Concurrency.dylib     0x5fde4 swift_job_runImpl(swift::Job*, swift::SerialExecutorRef) + 76
3  libdispatch.dylib              0x15d8c _dispatch_root_queue_drain + 392
4  libdispatch.dylib              0x16590 _dispatch_worker_thread2 + 156
5  libsystem_pthread.dylib        0x4c40 _pthread_wqthread + 228
6  libsystem_pthread.dylib        0x1488 start_wqthread + 8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests