I get this error
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0xb064425c
When the following function is called:
const std::map<FunctionID, std::string> getEnumElementsStringRepresentation() {
static bool is_initialized = false;
static std::map<FunctionID, std::string> enum_string_representation; // Fails here
if (false == is_initialized) {
enum_string_representation.insert(std::make_pair(FunctionID.capabilities, "capabilities"));
... many more similar inserts
is_initialized = true;
}
return enum_string_representation;
}
It appears to be a read/write error but I'm not sure the best way to debug.
You said your code is multi-threaded. Because of the function-static map
instance, getEnumElementsStringRepresentation
is not re-entrant (usually). You would have to protect the function with a mutex, or use thread-local storage.