xmtp/xmtp-ios

Bug: Framework can cause app to crash due to variable data race with async access

benjaminmayo opened this issue · 1 comments

Describe the bug

The internal conversationsByTopic property can be accessed and mutated from various threads simultaneously due to concurrency. As access to this storage is not gated by a lock or other synchronization, this can lead to malformed memory and cause unavoidable crashes when the framework accesses that property.

See screenshot for an example of where Xcode caught the error in the debugger:
Screenshot 2023-09-15 at 23 44 57

Expected behavior

The XMTP framework should not induce crashes.

Steps to reproduce the bug

Client code that invokes Conversations methods which internally mutate the conversationsByTopic storage will eventually trigger the crash. This was first observed due to app code that observed streamAllMessages() and then also invoked the list() method.

Thanks for flagging this. Great catch!