"Pointer being freed was not allocated"


#1

Hi,

I have been working with Realm in my iOS app for a while, with no real issues. I’m on the most recent version to date, 3.7.1. However, I recently began to try to integrate an iOS framework exported via Unity into my app. When I first add the Unity framework to my app via CocoaPods, before even referencing any of its methods, I get a crash triggered by a RLMNotificationListener thread:

> "malloc: *** error for object 0x11bc33f50: pointer being freed was not allocated."

This crash is fired the moment I try to add to or read from my Realm instance. It only happens when I’m debugging on my physical device. I’m also not sure Realm and Unity are the only two culprits-- when I build a test project with just Unity and Realm included as dependencies, there is no crash, but once I add the littlstar-ios 360 degree video player SDK, the crash occurred. However, there is no crash when Realm is not being called. It’s a mind-boggling crash because none of these frameworks interact with each other in this test project-- they’re just being added through CocoaPods.

I can’t provide terribly specific details because we’ve been very bewildered as to the actual cause of the crash. Some inspection has shown us that RLMRealm instances are explicitly deallocated in your source code, which leads us to think this is part of the problem, but I’m not sure if there is a workaround.

The following is a stack trace we achieved by using a malloc overriding memory manager that does not reuse memory, and adds detection for over/under runs (found here: ftp://gee.cs.oswego.edu/pub/misc/malloc.c):

Apologies for the lack of detail, but if any of this may describe an issue you’ve seen before that you may be able to help us work around, I would greatly appreciate any feedback you have. I’ll try to give any additional information I have if possible.