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 in Gist.invalidateTimer #839

Closed
dfed opened this issue Nov 25, 2024 · 3 comments · May be fixed by #840
Closed

Crash in Gist.invalidateTimer #839

dfed opened this issue Nov 25, 2024 · 3 comments · May be fixed by #840

Comments

@dfed
Copy link

dfed commented Nov 25, 2024

SDK version: 3.5.0 (though I believe also 3.6.0 – haven't shipped with that yet)

Environment: Production

Are logs available?
No. But we do have a crash log:

OS Version: iOS 18.1.1 (22B91)
Report Version: 104

Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0 at 0x000000018a9fd0d4
Crashed Thread: 2

Application Specific Information:
Signal 5, Code 0

Thread 2 Crashed:
0   CoreFoundation                  0x30d7c30d4         CF_IS_OBJC
1   CoreFoundation                  0x30d7bcfe8         [inlined] CFRetain
2   CoreFoundation                  0x30d7bcfe8         CFRetain
3   CoreFoundation                  0x30d8532e4         CFRunLoopTimerInvalidate
4   Tolan                           0x202de5ae0         [inlined] Gist.invalidateTimer (Gist.swift:70)
5   Tolan                           0x202de5ae0         Gist.setupPollingAndFetch (Gist.swift:130)
6   Tolan                           0x202de57ac         closure in Gist.setUserToken (Gist.swift:103)
7   Tolan                           0x202df8c70         closure in InAppMessageStoreManager.fetchState (InAppMessageManager.swift:82)
8   libswift_Concurrency.dylib      0x32460d100         swift::runJobInEstablishedExecutorContext

No other threads are working within Gist or other CustomerIO code. Note that we're calling identify(userId:traits:) from a queue other than main.

Describe the bug
A crash sometimes occurs when a timer is invalidated within CustomerIO.

To Reproduce
Unknown. We're seeing a few of these crashes in the wild in recent-ish builds.

Expected behavior
CustomerIO does not crash

Screenshots
N/A

Additional context
I see the following code in Gist.swift:

        // Timer must be scheduled on the main thread
        threadUtil.runMain {

It looks like we're invalidating the timer on a queue other than main. We probably want to only talk to the timer on main...

@mahmoud-elmorabea
Copy link

Thanks for reporting!

It seems like we won't be able to reproduce the issue which makes it difficult to look into.

Can you elaborate on how often does this happen? % of unique users or sessions? This would help us prioritize looking into the issue and it would definitely help if you are able to reproduce the issue and let us know when it happens.

@dfed
Copy link
Author

dfed commented Dec 4, 2024

This issue crashes a small percentage – about 1/10th of a percent – of all sessions.

I have not reproduced the issue locally, however it seems potentially easy to put up a speculative fix where you only interact with this timer from a single thread, regardless of what thread your code was called from. Working with mutable state across multiple queues is not a best practice, and is likely the cause of this crash.

@mahmoud-elmorabea
Copy link

Thanks for providing more info!

We have created a ticket on our backlog to look into adding a preventive fix for the issue.

@linear linear bot closed this as completed Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants