Search code examples
exc-bad-accessprotocol-buffersmessageui

Strange EXC_BAD_ACCESS in iOS App


I'm using MFMessageComposeViewController to send message in my view controller. Before importing Google Protobuf Lib, all the things works. But after importing the lib, I always get a EXC_BAD_ACCESS error at the line of:

MFMessageComposeViewController *messager = [[MFMessageComposeViewController alloc] init];

But in the Debug Navigator, I always get the following stack, which leads me to bool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddFile method in descriptor_database.cpp and then to bool InsertIfNotPresent method in map-util.h. Both descriptor_database.cpp and map-util.h are from Google Protobuf Lib.

Stack

I'm confused why the initialization of MFMessageComposeViewController has anything to do with Google Protobuf Lib.

Removing the lib can solve the problem, but it's needed in my communication engine.

I've googled around, with no answer found. Thanks if anyone can lead me to the right direction.

I'm not sure if those two screenshots help:

Screenshot 1 Screenshot 2


Solution

  • Change the protobuf library compiler option "Apple LLVM compiler 4.2 - Code Generation\Symbols Hidden by Default" to YES would solve this problem.