GoogleCloudPlatform / recaptcha-enterprise-mobile-sdk

Apache License 2.0
30 stars 6 forks source link

tokio::runtime crash on iOS 17.5+ #121

Open hartlco opened 3 months ago

hartlco commented 3 months ago

Describe the bug tokio::runtime used internally by recaptcha enterprise crashes iOS Application starting from iOS 17.5

reCAPTCHA Site Key Can be provided on request

Integration Method

SDK Version (e.g. 18.0.1): 18.2.0

To Reproduce We did not yet uncover a way to reproduce the crash. We only see it in our Crashlytics reports

Expected behavior The App should not crash

Xcode version for iOS (please complete the following information):

Device (please complete the following information):

Stack trace

0  libsystem_kernel.dylib         0x6edc kevent + 8
1  App                      0x562ba10 mio::poll::Poll::poll::hbd3b7a2e8ff63f46 + 1063976
2  App                      0x5623bd0 tokio::runtime::io::driver::Driver::turn::h42745a872b3d95ec + 1031656
3  App                      0x5622144 tokio::runtime::driver::IoStack::park_timeout::h16986c806463af54 + 1024860
4  App                      0x56244c0 tokio::runtime::time::Driver::park_internal::h07fe973b20f40920 + 1033944
5  App                      0x5622584 tokio::runtime::scheduler::current_thread::Context::enter::he93259525eae94ed + 1025948
6  App                      0x56223e0 tokio::runtime::scheduler::current_thread::Context::park::h72db5b37a4a10177 + 1025528
7  App                      0x553ba5c tokio::runtime::context::scoped::Scoped$LT$T$GT$::set::h84f0b8857b6a9fd6 + 81012
8  App                      0x552cacc std::thread::local::LocalKey$LT$T$GT$::with::h5075fe9627162ec4 + 19684
9  App                      0x553b918 tokio::runtime::context::set_scheduler::h71ada748441183e2 + 80688
10 App                      0x553c58c tokio::runtime::scheduler::current_thread::CoreGuard::enter::habea415c01d0139d + 83876
11 App                      0x553c5e8 tokio::runtime::scheduler::current_thread::CoreGuard::block_on::hb7b7aeff58ab8bca + 83968
12 App                      0x553bef4 tokio::runtime::context::runtime::enter_runtime::hfc6f633f09d42a6e + 82188
13 App                      0x553c26c tokio::runtime::scheduler::current_thread::CurrentThread::block_on::h5efabbcd84231095 + 83076
14 App                      0x553c038 tokio::runtime::runtime::Runtime::block_on::h5a6c5de31f78f9fc + 82512
15 App                      0x552bae0 std::sys_common::backtrace::__rust_begin_short_backtrace::ha617da18938cef51 + 15608
16 App                      0x552d5f0 core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::h2f04465a7f100bc8 + 22536
17 App                      0x564fc88 std::sys::unix::thread::Thread::new::thread_start::hc9a619cc2dedc6fa + 394 (mod.rs:394)
18 libsystem_pthread.dylib        0x72e4 _pthread_start + 136
19 libsystem_pthread.dylib        0x20fc thread_start + 8
walterjgsp commented 3 months ago

Thanks for the report @hartlco. It's really interesting because we never faced anything similar before and from my search the tokio::runtime is a Rust library that we don't use directly.

My first suggestion from the report would be to update the version of our SDK in the app to the latest one, we do some bug fixes and improvements at each major version and from 18.2.0 to the most recent 18.5.1 there's a lot of changes that could already have fixed that bug.

I will do some follow up questions to help us to do some investigation from our side.

  1. What's the ratio of exceptions that you're seeing this?
  2. Is this happening when calling the API getClient or the execute?
  3. Do you have some other stack trace that has any reCaptcha reference on it so can help us debug? From the stack trace that was provided there's no way of telling for sure what reCaptcha triggered that made it crash since there's no reference to reCaptcha.
hartlco commented 3 months ago

Thank you @walterjgsp for the fast reply. I will plan in updating the SDK version in the coming days.

What's the ratio of exceptions that you're seeing this?

It is happening very rarely, ratio roughly 0,025% of our crashes in the last 30 days

Is this happening when calling the API getClient or the execute?

It is happening at the getClient call. That is also how we isolated it coming from recaptcha, as we also do not use Rust in our App

Do you have some other stack trace that has any reCaptcha reference on it so can help us debug?

Do you have an email/form I can use to send a full stack trace?

walterjgsp commented 3 months ago

It is happening at the getClient call. That is also how we isolated it coming from recaptcha, as we also do not use Rust in our App

That's really interesting, thanks for letting us know. We will investigate to see where this tokio::runtime is coming from. All my shallow search pointed to Rust but could be something else.

Do you have an email/form I can use to send a full stack trace?

Please use this https://forms.gle/nTME7psR6gMwtSX69 to send the stack trace

walterjgsp commented 3 months ago

Thanks for sending the stacktrace @hartlco, we will keep investigating from our side.

About the plan to update the SDK. We will launch a new API that to retrieve a client that has built-in retries and it's more robust and stable. It's already available in beta version on the 18.6.0-beta01 that was released last week. We plan to release 18.6.0 stable soon.

mcorner commented 1 month ago

@hartlco are you still seeing this in the 18.6 SDKs?

hartlco commented 3 weeks ago

@mcorner @walterjgsp We are no longer seeing this issue but after updating to 18.6.0, a new crash in [RCAx_GPBAutocreatedArray addObject:] emerged. I'm uploading a new stacktrace through the form.

walterjgsp commented 3 weeks ago

Thanks for uploading the stack trace @hartlco. Do you know the ratio that this is happening to you? Are you using Swift or ObjC when developing the App? If it's happening all the time could you provide us with a repository with an code reproducing the error? Thanks

mcorner commented 3 weeks ago

@walterjgsp adding a nil would cause such a crash IIUC