BUG IN CLIENT OF LIBMALLOC: memory corruption of free block

We've noticed a pretty common crash that's occurring in our app that appears to only be affecting iOS 18 users. The code in question is below:

func getThing() async throws -> ThingData {
guard shouldRefresh, let data = self.thingData else {
let remoteThingData = try await store.getThingData()
self.thingData = remoteThingData
return remoteThingData // Crash happens here
}
return data
}

The crash happens on a background thread and the actual crash is: Crashed: com.apple.root.user-initiated-qos.cooperative EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x00000004a67149c0

We haven't been able to reproduce the error ourselves but in the past 90 days all of the crashes (several thousand) have been only on iOS 18.

We also found this thread that appears similar from 2 years ago but unsure if it's related because in our case the guard can only be calculated at runtime so there shouldn't be any optimizations happening.

Answered by DTS Engineer in 837441022

The BUG IN CLIENT OF LIBMALLOC message indicates a memory management problem. Memory management problems are tricky because the code where you notice the problem may not be related to the code that caused it. My general advice is that you deploy the standard memory debugging tools to see if you can make the issue more reproducible, and then debug things from there.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

The BUG IN CLIENT OF LIBMALLOC message indicates a memory management problem. Memory management problems are tricky because the code where you notice the problem may not be related to the code that caused it. My general advice is that you deploy the standard memory debugging tools to see if you can make the issue more reproducible, and then debug things from there.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

BUG IN CLIENT OF LIBMALLOC: memory corruption of free block
 
 
Q